diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-05-26 16:02:32 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-05-26 19:53:58 -0400 |
commit | 26980c6ec96369bbaf87be1e405594df8ec3f0dc (patch) | |
tree | 35f3e56abb22e4471eeb2525e12189a678642ec9 /test | |
parent | bd36ea22b670d52636dbe3f10cf6ce1e67d838b8 (diff) | |
download | jquery-26980c6ec96369bbaf87be1e405594df8ec3f0dc.tar.gz jquery-26980c6ec96369bbaf87be1e405594df8ec3f0dc.zip |
Fix #13939: Same-unit relative animations
(cherry picked from commit 00231d5d94d3374d53bfe79e04ba253250c73087)
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/effects.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js index d59ff84a6..05f1c017a 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -204,6 +204,46 @@ test("animate(Hash, Object, Function)", function() { }); }); +test("animate relative values", function() { + stop(); + + var value = 40, + bases = [ "%", "px", "em" ], + adjustments = [ "px", "em" ], + container = jQuery("<div></div>") + .css({ position: "absolute", height: "50em", width: "50em" }), + animations = bases.length * adjustments.length; + + expect( 2 * animations ); + + jQuery.each( bases, function( _, baseUnit ) { + jQuery.each( adjustments, function( _, adjustUnit ) { + var base = value + baseUnit, + adjust = { height: "+=2" + adjustUnit, width: "-=2" + adjustUnit }, + elem = jQuery("<div></div>") + .appendTo( container.clone().appendTo("#qunit-fixture") ) + .css({ + position: "absolute", + height: base, + width: value + adjustUnit + }), + baseScale = elem[ 0 ].offsetHeight / value, + adjustScale = elem[ 0 ].offsetWidth / value; + + elem.css( "width", base ).animate( adjust, 100, function() { + equal( this.offsetHeight, value * baseScale + 2 * adjustScale, + baseUnit + "+=" + adjustUnit ); + equal( this.offsetWidth, value * baseScale - 2 * adjustScale, + baseUnit + "-=" + adjustUnit ); + + if ( --animations === 0 ) { + start(); + } + }); + }); + }); +}); + test("animate negative height", function() { expect(1); stop(); |