Skip to content
Permalink
Browse files

Make sure that width or height don't animate to a negative value. Fixes

  • Loading branch information
jeresig committed Dec 5, 2009
1 parent 8d1efee commit b24da33f52f8ce536ae60a6cbffeb2f5cf02bac5
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/fx.js
  2. +9 −0 test/unit/fx.js
@@ -432,7 +432,7 @@ jQuery.extend( jQuery.fx, {

_default: function(fx){
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
} else {
fx.elem[ fx.prop ] = fx.now;
}
@@ -52,6 +52,15 @@ test("animate(Hash, Object, Function)", function() {
});
});

test("animate negative height", function() {
expect(1);
stop();
jQuery("#foo").animate({ height: -100 }, 100, function() {
equals( this.offsetHeight, 0, "Verify height." );
start();
});
});

/* // This test ends up being flaky depending upon the CPU load
test("animate option (queue === false)", function () {
expect(1);

0 comments on commit b24da33

Please sign in to comment.
You can’t perform that action at this time.