javascript - Disable onSlideChangeEnd listener -


i disabled onslidechangeend callback on swiper component.

if user clicks on arrows want execute onslidechangeend callback method, if programatically want slide particular image not want onslidechangeend called. otherwise messy listener loop situations.

how do this?

i thinking of having kind of flag. if flag set false, callback code not executed, :

    gallerytop = new swiper('.gallery-top-product-view', { //'.gallery-top'         nextbutton: '.swiper-button-next',         prevbutton: '.swiper-button-prev',         spacebetween: 10,         onslidechangeend: function (swiper) {             if(someflag)                 doit();          }     }); 

however callback object seems reference old variable value. 'someflag' seems random when use :

    someflag= true;      gallerytop.slideto(key);      someflag= false; 

am missing fundamental in how should disable listeners?

according swiper documentation ( http://www.idangero.us/swiper/api/ ) can pass third param runcallbacks false prevent callbacks execution: gallerytop.slideto(key, speed, false);


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -