Skip to content

Commit 0a98623

Browse files
committed
Effects: manually revert two requestAnimationFrame commits
72119e0 and bbdfbb4
1 parent 741fe39 commit 0a98623

File tree

2 files changed

+4
-57
lines changed

2 files changed

+4
-57
lines changed

src/effects.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ var
2323
rfxtypes = /^(?:toggle|show|hide)$/,
2424
rrun = /queueHooks$/;
2525

26-
function raf() {
27-
if ( timerId ) {
28-
window.requestAnimationFrame( raf );
29-
jQuery.fx.tick();
30-
}
31-
}
32-
3326
// Animations created synchronously will run synchronously
3427
function createFxNow() {
3528
window.setTimeout( function() {
@@ -408,15 +401,8 @@ jQuery.speed = function( speed, easing, fn ) {
408401
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
409402
};
410403

411-
// Go to the end state if fx are off or if document is hidden
412-
if ( jQuery.fx.off || document.hidden ) {
413-
opt.duration = 0;
414-
415-
} else {
416-
opt.duration = typeof opt.duration === "number" ?
417-
opt.duration : opt.duration in jQuery.fx.speeds ?
418-
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
419-
}
404+
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
405+
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
420406

421407
// Normalize opt.queue - true/undefined/null -> "fx"
422408
if ( opt.queue == null || opt.queue === true ) {
@@ -620,18 +606,12 @@ jQuery.fx.timer = function( timer ) {
620606
jQuery.fx.interval = 13;
621607
jQuery.fx.start = function() {
622608
if ( !timerId ) {
623-
timerId = window.requestAnimationFrame ?
624-
window.requestAnimationFrame( raf ) :
625-
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
609+
timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
626610
}
627611
};
628612

629613
jQuery.fx.stop = function() {
630-
if ( window.cancelAnimationFrame ) {
631-
window.cancelAnimationFrame( timerId );
632-
} else {
633-
window.clearInterval( timerId );
634-
}
614+
window.clearInterval( timerId );
635615

636616
timerId = null;
637617
};

test/unit/effects.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ if ( !jQuery.fx ) {
55
return;
66
}
77

8-
var oldRaf = window.requestAnimationFrame;
9-
108
QUnit.module( "effects", {
119
setup: function() {
12-
window.requestAnimationFrame = null;
1310
this.sandbox = sinon.sandbox.create();
1411
this.clock = this.sandbox.useFakeTimers( 505877050 );
1512
this._oldInterval = jQuery.fx.interval;
@@ -22,7 +19,6 @@ QUnit.module( "effects", {
2219
jQuery.now = Date.now;
2320
jQuery.fx.stop();
2421
jQuery.fx.interval = this._oldInterval;
25-
window.requestAnimationFrame = oldRaf;
2622
return moduleTeardown.apply( this, arguments );
2723
}
2824
} );
@@ -2317,35 +2313,6 @@ QUnit.test( "Respect display value on inline elements (#14824)", function( asser
23172313
clock.tick( 800 );
23182314
} );
23192315

2320-
QUnit.test( "Animation should go to its end state if document.hidden = true", function( assert ) {
2321-
assert.expect( 1 );
2322-
2323-
var height;
2324-
if ( Object.defineProperty ) {
2325-
2326-
// Can't rewrite document.hidden property if its host property
2327-
try {
2328-
Object.defineProperty( document, "hidden", {
2329-
get: function() {
2330-
return true;
2331-
}
2332-
} );
2333-
} catch ( e ) {}
2334-
} else {
2335-
document.hidden = true;
2336-
}
2337-
2338-
if ( document.hidden ) {
2339-
height = jQuery( "#qunit-fixture" ).animate( { height: 500 } ).height();
2340-
2341-
assert.equal( height, 500, "Animation should happen immediately if document.hidden = true" );
2342-
jQuery( document ).removeProp( "hidden" );
2343-
2344-
} else {
2345-
assert.ok( true, "Can't run the test since we can't reproduce correct environment for it" );
2346-
}
2347-
} );
2348-
23492316
QUnit.test( "jQuery.easing._default (gh-2218)", function( assert ) {
23502317
assert.expect( 2 );
23512318

0 commit comments

Comments
 (0)