Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

1 participant

@gnarf
Owner

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 referenced this pull request from a commit
@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 referenced this pull request from a commit in mescoda/jquery
@gnarf gnarf Ensure each tick gets it's own fxNow - Fixes #12837 - Thanks @chadparry
Closes gh-1022
Closes gh-1021
876076f
@bperel bperel referenced this pull request from a commit
@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 authored
    …animations queued outside of this loop - Fixes #12837 - Thanks @chadparry
This page is out of date. Refresh to see the latest.
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.