mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Ensure each tick gets it's own fxNow - Fixes #12837 - Thanks @chadparry
Closes gh-1022 Closes gh-1021
This commit is contained in:
parent
6b14cef7a8
commit
781a5c0b78
3
src/effects.js
vendored
3
src/effects.js
vendored
@ -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 ) {
|
||||
|
29
test/unit/effects.js
vendored
29
test/unit/effects.js
vendored
@ -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" );
|
||||
|
Loading…
Reference in New Issue
Block a user