]> source.dussan.org Git - jquery.git/commitdiff
Makes sure each animation tick has the same timestamp for all animations in the batch.
authorjaubourg <j@ubourg.net>
Thu, 7 Apr 2011 03:07:20 +0000 (05:07 +0200)
committerjaubourg <j@ubourg.net>
Thu, 7 Apr 2011 03:07:20 +0000 (05:07 +0200)
src/effects.js

index d9e9a8b3137bfb51b2f065dda34ed2591ba07375..5ff85d1311d163dbf6d98ddc18be3394de9adb02 100644 (file)
@@ -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;