So i call a navigateRight function every 3 seconds.
WrappingCarousel.prototype.startSlideShow = function() {
var self = this;
clearInterval(this.slideShowInterval);
this.slideShowInterval = setInterval(function () {
self.navigateRight(true);
}, 3000);
};
WrappingCarousel.prototype.navigateRight = function(notRestart) {
if ($("#catalog").hasClass("screen0") && $("#catalog-content").is(":visible")) {
clearInterval(this.startSlideShow); // -----> I CLEAR IT HERE.
}
if (this.index+1 >= this.items.length) { this.index = -1; }
if (!notRestart) this.startSlideShow();
return Carousel.prototype.navigateRight.call(this);
};
Inside function which calls every 3 seconds i have an condition, which should clear this interval, but it doesn't clear it at all.
Please, try with clearInterval(this.slideShowInterval)
inside the navigateRight
function, which seems to be the right variable you used to store the value returned by the setInterval
function, instead of clearInterval(this.startSlideShow)
.
More here:
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearInterval
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.