Skip to content
Permalink
Browse files

Followup to #11469; add test case and clarify code.

  • Loading branch information...
sindresorhus authored and dmethvin committed Apr 5, 2012
1 parent d5ee856 commit fdf37de77882204cafeba2f10fb5b9915b6e4b93
Showing with 12 additions and 2 deletions.
  1. +3 −2 src/effects.js
  2. +9 −0 test/unit/effects.js
@@ -4,6 +4,7 @@ var elemdisplay = {},
iframe, iframeDoc,
rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
rMarginProp = /^margin/,
timerId,
fxAttrs = [
// height animations
@@ -636,8 +637,8 @@ jQuery.extend( jQuery.fx, {

// Ensure props that can't be negative don't go there on undershoot easing
jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
// exclude marginTop, marginLeft, marginBottom and marginRight from this list
if ( prop.indexOf( "margin" ) ) {
// Exclude marginTop, marginLeft, marginBottom and marginRight from this list
if ( !rMarginProp.test( prop ) ) {
jQuery.fx.step[ prop ] = function( fx ) {
jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
};
@@ -263,6 +263,15 @@ test("animate negative height", function() {
});
});

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

test("animate negative padding", function() {
expect(1);
stop();

0 comments on commit fdf37de

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