I have image slider where images replace each other by timeout. I use jQuery function setInterval() but there is a small problem, after minimizing browser windows this function keep "working", and where I restore browser window images replace each other with incrediable high speed, like the whole time after window was minimized setInterval() collect actions but executing them after restoring the window.
How to pause setInterval() on browser minimize or keep swap images when windows is minimized?
The documentation for animate() explicitly mentions:
So, you can either call
setTimeout()
in the callback of your animation to chain the next cycle, if possible, orqueue()
the calls tosetTimeout()
between the calls toanimate()
.EDIT: As requested in comments, here is a simple
queue()
example. The code below enforces a two-second delay between the slide animations: