Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #11415: Stop non-negative prop undershoot on animation.
This doesn't fix *all* of them (see the ticket for a supposedly complete list) but these were already handy so it was relatively cheap to fix them. If you need others fixed, add a custom step function as was done here. Thanks @scott_gonzalez!
  • Loading branch information
dmethvin committed Mar 2, 2012
1 parent a52391a commit 5642626
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/effects.js
Expand Up @@ -634,9 +634,8 @@ jQuery.extend( jQuery.fx, {
}
});

// Adds width/height step functions
// Do not set anything below 0
jQuery.each([ "width", "height" ], function( i, prop ) {
// Ensure props that can't be negative don't go there on undershoot easing
jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
jQuery.fx.step[ prop ] = function( fx ) {
jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
};
Expand Down
9 changes: 9 additions & 0 deletions test/unit/effects.js
Expand Up @@ -263,6 +263,15 @@ test("animate negative height", function() {
});
});

test("animate negative padding", function() {
expect(1);
stop();
jQuery("#foo").animate({ paddingBottom: -100 }, 100, function() {
equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
start();
});
});

test("animate block as inline width/height", function() {
expect(3);

Expand Down

0 comments on commit 5642626

Please sign in to comment.