From: louisremi Date: Wed, 2 Feb 2011 10:25:09 +0000 (+0100) Subject: first tick should not occur immediatly; no tick should happen after a stop() X-Git-Tag: 1.6b1~26^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c95ab2a39c178eee47ce7b1cbdffa812d7914bb6;p=jquery.git first tick should not occur immediatly; no tick should happen after a stop() + comments --- diff --git a/src/effects.js b/src/effects.js index 12b87bd4e..e5a10295c 100644 --- a/src/effects.js +++ b/src/effects.js @@ -363,17 +363,16 @@ jQuery.fx.prototype = { t.elem = this.elem; if ( t() && jQuery.timers.push(t) && !timerId ) { - if ( jQuery.support.requestAnimationFrame ) { - timerId = true; - (function raf() { + // Use requestAnimationFrame instead of setInterval if available + ( timerId = jQuery.support.requestAnimationFrame ) ? + window[timerId](function raf() { + // timerId will be true as long as the animation hasn't been stopped if (timerId) { - window[jQuery.support.requestAnimationFrame](raf); + window[timerId](raf); + fx.tick(); } - fx.tick(); - })(); - } else { + }): timerId = setInterval(fx.tick, fx.interval); - } } },