You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you have a carousel and call several times the cycle method, then calling the pause method does not work
Expected behavior
it doesn't matter how many time you call cycle. If after a few calls to cycle you call pause, the carousel should pause
Additional context
The cycle method is:
/** * Set an interval to cycle through the carousel items */Carousel.prototype.cycle=function(){var_this=this;if(typeofwindow!=='undefined'){this._intervalInstance=window.setInterval(function(){_this.next();},this._intervalDuration);}};
As you can see, it doesn't check if it already had a called setInterval before, so calling it several times will make impossible to stop the timer. The proper fix can be something like this:
/** * Set an interval to cycle through the carousel items */Carousel.prototype.cycle=function(){var_this=this;if(this._intervalInstance){clearInterval(this._intervalInstance);this._intervalInstance=null;}if(typeofwindow!=='undefined'){this._intervalInstance=window.setInterval(function(){_this.next();},this._intervalDuration);}};Pleasefixit/** * Clears the cycling interval */Carousel.prototype.pause=function(){if(this._intervalInstance){clearInterval(this._intervalInstance);this._intervalInstance=null;}};
The text was updated successfully, but these errors were encountered:
Describe the bug
If you have a carousel and call several times the cycle method, then calling the pause method does not work
Expected behavior
it doesn't matter how many time you call cycle. If after a few calls to cycle you call pause, the carousel should pause
Additional context
The cycle method is:
As you can see, it doesn't check if it already had a called setInterval before, so calling it several times will make impossible to stop the timer. The proper fix can be something like this:
The text was updated successfully, but these errors were encountered: