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() {
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 ) {
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;
};
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;
jQuery.now = Date.now;
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
- window.requestAnimationFrame = oldRaf;
return moduleTeardown.apply( this, arguments );
}
} );
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 );