Skip to content

Commit 5642626

Browse files
committed
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!
1 parent a52391a commit 5642626

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/effects.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,8 @@ jQuery.extend( jQuery.fx, {
634634
}
635635
});
636636

637-
// Adds width/height step functions
638-
// Do not set anything below 0
639-
jQuery.each([ "width", "height" ], function( i, prop ) {
637+
// Ensure props that can't be negative don't go there on undershoot easing
638+
jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
640639
jQuery.fx.step[ prop ] = function( fx ) {
641640
jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
642641
};

test/unit/effects.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ test("animate negative height", function() {
263263
});
264264
});
265265

266+
test("animate negative padding", function() {
267+
expect(1);
268+
stop();
269+
jQuery("#foo").animate({ paddingBottom: -100 }, 100, function() {
270+
equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
271+
start();
272+
});
273+
});
274+
266275
test("animate block as inline width/height", function() {
267276
expect(3);
268277

0 commit comments

Comments
 (0)