Skip to content

Loading…

#12837 - Ensure each tick gets it's own fxNow #1022

Closed
wants to merge 1 commit into from

1 participant

@gnarf
jQuery Foundation member

Leave the old stuff around for animations queued outside of this loop - Fixes #12837 - Thanks @chadparry

Based on discussion in gh-1015 and gh-1021

Sizes - compared to master @ 0ee94159023bebe1992c5281d0f4778b4f75ff0d
    266832       (+44)  dist/jquery.js                                         
     93120       (+16)  dist/jquery.min.js                                     
     33183        (+7)  dist/jquery.min.js.gz
@gnarf gnarf Ensure each tick gets it's own fxNow, leave the old stuff around for …
…animations queued outside of this loop - Fixes #12837 - Thanks @chadparry
51ba322
@gnarf gnarf closed this in 781a5c0
@gnarf gnarf added a commit that referenced this pull request
@gnarf gnarf Ensure each tick gets it's own fxNow - Fixes #12837 - Thanks @chadparry
Closes gh-1022
Closes gh-1021
(cherry picked from commit 781a5c0)
c56732f
@mescoda mescoda pushed a commit to mescoda/jquery that referenced this pull request
@gnarf gnarf Ensure each tick gets it's own fxNow - Fixes #12837 - Thanks @chadparry
Closes gh-1022
Closes gh-1021
876076f
@bperel bperel pushed a commit that referenced this pull request
@gnarf gnarf Ensure each tick gets it's own fxNow - Fixes #12837 - Thanks @chadparry
Closes gh-1022
Closes gh-1021
(cherry picked from commit 781a5c0)
1e432c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 7, 2012
  1. @gnarf

    Ensure each tick gets it's own fxNow, leave the old stuff around for …

    gnarf committed
    …animations queued outside of this loop - Fixes #12837 - Thanks @chadparry
Showing with 32 additions and 0 deletions.
  1. +3 −0 src/effects.js
  2. +29 −0 test/unit/effects.js
View
3 src/effects.js
@@ -612,6 +612,8 @@ jQuery.fx.tick = function() {
timers = jQuery.timers,
i = 0;
+ fxNow = jQuery.now();
+
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
// Checks the timer has not already been removed
@@ -623,6 +625,7 @@ jQuery.fx.tick = function() {
if ( !timers.length ) {
jQuery.fx.stop();
}
+ fxNow = undefined;
};
jQuery.fx.timer = function( timer ) {
View
29 test/unit/effects.js
@@ -1818,6 +1818,35 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117
});
});
+test( "Each tick of the timer loop uses a fresh time (#12837)", function() {
+ var lastVal, current,
+ tmp = jQuery({
+ test: 0
+ });
+ expect( 3 );
+ tmp.animate({
+ test: 100
+ }, {
+ step: function( p, fx ) {
+ ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now );
+ lastVal = fx.now;
+ }
+ });
+ current = jQuery.now();
+ // intentionally empty, we want to spin wheels until the time changes.
+ while ( current === jQuery.now() ) { }
+
+ // now that we have a new time, run another tick
+ jQuery.fx.tick();
+
+ current = jQuery.now();
+ // intentionally empty, we want to spin wheels until the time changes.
+ while ( current === jQuery.now() ) { }
+
+ jQuery.fx.tick();
+ tmp.stop();
+});
+
test( "Animations with 0 duration don't ease (#12273)", 1, function() {
jQuery.easing.test = function() {
ok( false, "Called easing" );
Something went wrong with that request. Please try again.