From c95ab2a39c178eee47ce7b1cbdffa812d7914bb6 Mon Sep 17 00:00:00 2001 From: louisremi Date: Wed, 2 Feb 2011 11:25:09 +0100 Subject: [PATCH] first tick should not occur immediatly; no tick should happen after a stop() + comments --- src/effects.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/effects.js b/src/effects.js index 12b87bd4..e5a10295 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); - } } },