I'm doing a content slider that automatically cycles slides (by periodically calling the "next" function using setInterval
)but stops when the user click on a prev/next buttons (by using clearInterval
on the prev/next buttons). Is there a way to use setInterval
again after a few seconds of clicking the button?
Code:
// start to automatically cycle slides
var cycleTimer = setInterval(function () {
$scroll.trigger('next');
}, 450);
// set next/previous buttons as clearInterval triggers
var $stopTriggers = $('img.right').add('img.left'); // left right
// function to stop auto-cycle
function stopCycle() {
clearInterval(cycleTimer);
}