javascript - How to call function onclick on layer -


here using framerjs, trying call function changes position of other layers. when click on layer product_scroller value of curpage changes , replaced product_details , function changepos() called. here onclick product_scroller changepos() not working first time.but when click second time working. how avoid this. want call changepos() on 1 click.

product_scroller.on(events.click,function(){  curpage = product_scroller.currentpage  setinterval(   changepos(), 1000); })    function changepos(){         curpage = product_scroller.currentpage;         if(curpage == product_details)         {           product_description1.y=1630           product_description2.y=1855           product_description3.y=2080           product_description4.y=2305           footer.y = 2570           carousel.y = 2570          } else if (curpage == product_details2) {             product_description1.y=1100           product_description2.y=1325           product_description3.y=1550           product_description4.y=1775           footer.y = 2030           carousel.y = 2030          } else {             console.log("no outcome");         } } 


Comments