Effects: manually revert two requestAnimationFrame commits

72119e0023 and bbdfbb4ee8
This commit is contained in:
Oleg Gaidarenko 2015-11-13 20:00:39 +03:00
parent 741fe39ac8
commit 0a98623abb
2 changed files with 4 additions and 57 deletions

28
src/effects.js vendored
View File

@ -23,13 +23,6 @@ var
rfxtypes = /^(?:toggle|show|hide)$/,
rrun = /queueHooks$/;
function raf() {
if ( timerId ) {
window.requestAnimationFrame( raf );
jQuery.fx.tick();
}
}
// Animations created synchronously will run synchronously
function createFxNow() {
window.setTimeout( function() {
@ -408,15 +401,8 @@ jQuery.speed = function( speed, easing, fn ) {
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
};
// Go to the end state if fx are off or if document is hidden
if ( jQuery.fx.off || document.hidden ) {
opt.duration = 0;
} else {
opt.duration = typeof opt.duration === "number" ?
opt.duration : opt.duration in jQuery.fx.speeds ?
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
}
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
// Normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) {
@ -620,18 +606,12 @@ jQuery.fx.timer = function( timer ) {
jQuery.fx.interval = 13;
jQuery.fx.start = function() {
if ( !timerId ) {
timerId = window.requestAnimationFrame ?
window.requestAnimationFrame( raf ) :
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
}
};
jQuery.fx.stop = function() {
if ( window.cancelAnimationFrame ) {
window.cancelAnimationFrame( timerId );
} else {
window.clearInterval( timerId );
}
window.clearInterval( timerId );
timerId = null;
};

33
test/unit/effects.js vendored
View File

@ -5,11 +5,8 @@ if ( !jQuery.fx ) {
return;
}
var oldRaf = window.requestAnimationFrame;
QUnit.module( "effects", {
setup: function() {
window.requestAnimationFrame = null;
this.sandbox = sinon.sandbox.create();
this.clock = this.sandbox.useFakeTimers( 505877050 );
this._oldInterval = jQuery.fx.interval;
@ -22,7 +19,6 @@ QUnit.module( "effects", {
jQuery.now = Date.now;
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
window.requestAnimationFrame = oldRaf;
return moduleTeardown.apply( this, arguments );
}
} );
@ -2317,35 +2313,6 @@ QUnit.test( "Respect display value on inline elements (#14824)", function( asser
clock.tick( 800 );
} );
QUnit.test( "Animation should go to its end state if document.hidden = true", function( assert ) {
assert.expect( 1 );
var height;
if ( Object.defineProperty ) {
// Can't rewrite document.hidden property if its host property
try {
Object.defineProperty( document, "hidden", {
get: function() {
return true;
}
} );
} catch ( e ) {}
} else {
document.hidden = true;
}
if ( document.hidden ) {
height = jQuery( "#qunit-fixture" ).animate( { height: 500 } ).height();
assert.equal( height, 500, "Animation should happen immediately if document.hidden = true" );
jQuery( document ).removeProp( "hidden" );
} else {
assert.ok( true, "Can't run the test since we can't reproduce correct environment for it" );
}
} );
QUnit.test( "jQuery.easing._default (gh-2218)", function( assert ) {
assert.expect( 2 );