Skip to content Skip to sidebar Skip to footer

Simple Slider With SetInterval() With Strange Behavier

I'm trying to make simple slider by using setinterval and jquery. you can have a look here http://jsfiddle.net/5m2Dq/ Slider works fine when it is in focus on browser but when we

Solution 1:

This occurs probably because your browser starts missing timeouts. Especially if you are viewing another tab, the browser thinks that it is not important to call the callback with exactly 2 second intervals. You should ditch the setInterval function altogether! Use instead the completion callback of fadeOut and fadeIn to trigger the effects.

Try something like

var cycle = function() {
   $('#fbLoginSlide :eq(0)').fadeOut('slow').hide()
   .next('div.loginSlide').fadeIn('slow', function() { setTimeout(cycle, 1500); })
   .end().appendTo('#fbLoginSlide');
};
cycle();

Post a Comment for "Simple Slider With SetInterval() With Strange Behavier"