mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 07:55:09 -05:00
Effects: Improve raf logic
* Make animation behave as if jQuery.fx.off = true if document is hidden * Use cancelAnimationFrame in jQuery.fx.stop Closes gh-1578
This commit is contained in:
28
test/unit/effects.js
vendored
28
test/unit/effects.js
vendored
@@ -2183,4 +2183,32 @@ test( "Respect display value on inline elements (#14824)", 2, function() {
|
||||
clock.tick( 800 );
|
||||
});
|
||||
|
||||
test( "Animation should go to its end state if document.hidden = true", 1, function() {
|
||||
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();
|
||||
|
||||
equal( height, 500, "Animation should happen immediately if document.hidden = true" );
|
||||
jQuery( document ).removeProp( "hidden" );
|
||||
|
||||
} else {
|
||||
ok( true, "Can't run the test since we can't reproduce correct environment for it" );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user