From 0a98623abb85bdce079b400ed3bf3d87ddc6b1da Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Fri, 13 Nov 2015 20:00:39 +0300 Subject: [PATCH] Effects: manually revert two `requestAnimationFrame` commits 72119e0023dcc0d9807caf6d988598b74abdc937 and bbdfbb4ee859fe9319b348d88120ddc2c9efbd63 --- src/effects.js | 28 ++++------------------------ test/unit/effects.js | 33 --------------------------------- 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/effects.js b/src/effects.js index ab6fe6d79..d8997f4be 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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; }; diff --git a/test/unit/effects.js b/test/unit/effects.js index 20b15a1ca..8d5b2b485 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -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 ); -- 2.39.5