Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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...
commit 56426261f0ee97d6d2f903d08b137a6f5f2c0916 1 parent a52391a
@dmethvin dmethvin authored
Showing with 11 additions and 3 deletions.
  1. +2 −3 src/effects.js
  2. +9 −0 test/unit/effects.js
View
5 src/effects.js
@@ -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 );
};
View
9 test/unit/effects.js
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.