diff options
author | louisremi <louisremi@louisremi-laptop.(none)> | 2011-02-02 10:26:04 +0100 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-04-04 15:46:37 -0400 |
commit | 15e34d1f07d0c687d040af22dbc66f3978715217 (patch) | |
tree | 5897ec4fdb5ada1cf4315da6a7355e3c8ea71b2b /src/effects.js | |
parent | 03e6f7235bd671330f807642fefd297c42413c45 (diff) | |
download | jquery-15e34d1f07d0c687d040af22dbc66f3978715217.tar.gz jquery-15e34d1f07d0c687d040af22dbc66f3978715217.zip |
reduce impact of requestAnimationFrame on incompatible browsers by minimizing number of lookups
Diffstat (limited to 'src/effects.js')
-rw-r--r-- | src/effects.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/effects.js b/src/effects.js index 6a72a88fd..12b87bd4e 100644 --- a/src/effects.js +++ b/src/effects.js @@ -363,9 +363,17 @@ jQuery.fx.prototype = { t.elem = this.elem; if ( t() && jQuery.timers.push(t) && !timerId ) { - timerId = jQuery.support.requestAnimationFrame ? - !window[jQuery.support.requestAnimationFrame](fx.tick): - setInterval(fx.tick, fx.interval); + if ( jQuery.support.requestAnimationFrame ) { + timerId = true; + (function raf() { + if (timerId) { + window[jQuery.support.requestAnimationFrame](raf); + } + fx.tick(); + })(); + } else { + timerId = setInterval(fx.tick, fx.interval); + } } }, @@ -470,8 +478,6 @@ jQuery.extend( jQuery.fx, { if ( !timers.length ) { jQuery.fx.stop(); - } else if ( jQuery.support.requestAnimationFrame && timerId) { - window[jQuery.support.requestAnimationFrame](jQuery.fx.tick); } }, |