diff options
author | jaubourg <j@ubourg.net> | 2011-04-07 05:07:20 +0200 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-04-07 05:07:20 +0200 |
commit | 75a4bc4a4e55360c7c3c734cbef2558050ed4456 (patch) | |
tree | c8f15dc14dd1a7ec868562217cd24415733e1669 /src/effects.js | |
parent | b7dd8404c52518bc4d71b0e715c506252d651a3f (diff) | |
download | jquery-75a4bc4a4e55360c7c3c734cbef2558050ed4456.tar.gz jquery-75a4bc4a4e55360c7c3c734cbef2558050ed4456.zip |
Makes sure each animation tick has the same timestamp for all animations in the batch.
Diffstat (limited to 'src/effects.js')
-rw-r--r-- | src/effects.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/effects.js b/src/effects.js index d9e9a8b31..5ff85d131 100644 --- a/src/effects.js +++ b/src/effects.js @@ -11,7 +11,17 @@ var elemdisplay = {}, [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], // opacity animations [ "opacity" ] - ]; + ], + fxNow; + +function clearFxNow() { + fxNow = undefined; +} + +function createFxNow() { + setTimeout( clearFxNow, 0 ); + return ( fxNow = jQuery.now() ); +} jQuery.fn.extend({ show: function( speed, easing, callback ) { @@ -349,7 +359,7 @@ jQuery.fx.prototype = { var self = this, fx = jQuery.fx; - this.startTime = jQuery.now(); + this.startTime = fxNow || createFxNow(); this.start = from; this.end = to; this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); @@ -394,7 +404,8 @@ jQuery.fx.prototype = { // Each step of an animation step: function( gotoEnd ) { - var t = jQuery.now(), done = true; + var t = fxNow || createFxNow(), + done = true; if ( gotoEnd || t >= this.options.duration + this.startTime ) { this.now = this.end; |