Skip to content

Commit 58ed62e

Browse files
gnarfdmethvin
authored andcommitted
Effects: 1.8 Animation Rewrite - thanks @mikesherov and @gibson042
1 parent 8ad22a2 commit 58ed62e

File tree

4 files changed

+618
-546
lines changed

4 files changed

+618
-546
lines changed

src/css.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
(function( jQuery ) {
22

3+
jQuery.cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4+
35
var ralpha = /alpha\([^)]*\)/i,
46
ropacity = /opacity=([^)]*)/,
57
// fixed for IE9, see #8346
68
rupper = /([A-Z]|^ms)/g,
7-
rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
9+
rnumsplit = /^([\-+]?(?:\d*\.)?\d+)(.*)$/i,
810
rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
911
rrelNum = /^([\-+])=([\-+.\de]+)/,
1012
rmargin = /^margin/,
1113

1214
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
1315

1416
// order is important!
15-
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
17+
cssExpand = jQuery.cssExpand,
1618
cssPrefixes = [ "O", "Webkit", "Moz", "ms" ],
1719

1820
curCSS;
@@ -264,6 +266,13 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
264266
};
265267
}
266268

269+
function setPositiveNumber( elem, value ) {
270+
var matches = rnumsplit.exec( value );
271+
return matches ?
272+
Math.max( 0, matches[ 1 ] ) + ( matches [ 2 ] || "px" )
273+
: value;
274+
}
275+
267276
function getWidthOrHeight( elem, name, extra ) {
268277

269278
// Start with offset property, which is equivalent to the border-box value
@@ -348,11 +357,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
348357
}
349358
},
350359

351-
set: function( elem, value ) {
352-
return rnum.test( value ) ?
353-
value + "px" :
354-
value;
355-
}
360+
set: setPositiveNumber
356361
};
357362
});
358363

@@ -436,7 +441,6 @@ jQuery.each({
436441
padding: "",
437442
border: "Width"
438443
}, function( prefix, suffix ) {
439-
440444
jQuery.cssHooks[ prefix + suffix ] = {
441445
expand: function( value ) {
442446
var i,
@@ -453,6 +457,10 @@ jQuery.each({
453457
return expanded;
454458
}
455459
};
460+
461+
if ( !rmargin.test( prefix ) ) {
462+
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
463+
}
456464
});
457465

458466
})( jQuery );

0 commit comments

Comments
 (0)