How can I reset the auto-scroll interval on my jCarouselLite carousel after some event so that it lets you look at the content for the full interval, regardless of how far along the timer was when you clicked next or previous? Right now, if I click next or previous after 9 seconds, it scrolls again after 1 second.
In the jCarouselLite source code on lines 274-277 is where the auto-scroll is implemented using setInterval
. I know you can use clearInterval
if you have the ID returned by setInterval, but there isn't one I can get outside of modifying the source code, and I don't want to do that.
Any ideas? Thanks!
If you are able/authorized to change the plugin code:
Add a variable to save the interval id to the plugins defaults
Search for:
Take the code which is executed here and make an internal function with it like:
Now just save the interval to your defined variable but clear it first:
Search for the
go()
function in the plugin and add arunAuto()
, so each time the function go is called it resets the interval.Of course you must also add the
runAuto()
call toif(o.auto)
so the interval starts at first.jCarouselLite itself doesn't provide any easy way to stop the auto-scrolling, which is an easier problem then do what you seem to want (?did I understand this right: You just want the autoscroll to temporarily stop on click and then continue)
Hacky + potentially buggy way to stop the autoscroll altogether
Real solution
As we can't get jCarouselLite to do this on its own we simulate the
auto
behavior ourself.None of these answers were what I was looking for, but this is what comes up when I Google 'jcarousellite reset timer', so for the next person looking to:
Then this is what I put together that works for me:
Just swap it out with your current jCarouselLite script and use it just the same.
Here's a version with a pause on mouseover built-in. Works nicely. http://github.com/cheald/jcarousel-lite