This problem has several reasons that all work together in a perfect storm:
- You put the next slides based solely on the timer, when you should queue up the callback of the previous slide animation,
- You are using a browser that supports requestAnimationFrame, and
- You are using jQuery 1.6.2, which includes support for requestAnimationFrame.
When you move away from the tab in which the slider works, a browser with support for requestAnimationFrame will stop all animations running on this tab. However, timers will continue to work! When you return to the page, all the queues in the queue are waiting immediately, which gives you this fleeing effect.
To fix this, the easiest solution would be to switch to jQuery 1.7.1, as they refused support for requestAnimationFrame () due to inconsistent browser support. But in the end they will return it, so you really need to fix your code.
To fix your code, you must queue a new slide animation in the callback of the previous slide .animate() . This ensures that you do not become blind, even if the animation is not running.
Let me know if you need more clarification. tl; dr: Change this:
<script src="js/jquery-1.6.1.min.js" type="text/javascript"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
For this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
The jQuery error on this issue has additional information: http://bugs.jquery.com/ticket/9381
source share