Reputation: 271
I have been working on our website and noticed that the slider on the homepage speeds up when the user clicks on the next button.
It slides OK when you don't select the next arrow, but suddenly speeds up when you do.
I think this is what is causing it to speed up:
$(document).ready(function () {
setTimeout("$('.caro-arrow.caro-arrow-r').click()", 8000);
$('.caro-arrow.caro-arrow-r').click( function () {
setTimeout("$('.caro-arrow.caro-arrow-r').click()", 8000);
});
})
Does anyone have any ideas how I can fix it so that it doesn't slide quicker when the next arrow is selected?
Thanks
Upvotes: 3
Views: 92
Reputation: 5356
You should clear the setTimeout
var clears='';
setInterval("$('.caro-arrow.caro-arrow-r').click()", 8000);
$('.caro-arrow.caro-arrow-r').click( function () {
clearTimeout(clears);
clears = setTimeout(function(){changeSliderFunction()/*call change slider image function*/}, 8000);
});
when user click the arrow click start time executed if user click continously then setTimeout execute many times and it increases slider speed
Upvotes: 2