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:
Oleg Gaidarenko
2014-05-12 21:53:40 +04:00
parent 72119e0023
commit 708764f47b
2 changed files with 46 additions and 21 deletions

28
test/unit/effects.js vendored
View File

@@ -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" );
}
});
})();