aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2012-04-23 15:05:12 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-04-23 15:05:12 -0400
commit58ed62ed12cb48d9224f699e86e197804ca5ece4 (patch)
tree9acdcb4ccb6e4ef4d2d20b887b82a476aa3e8e47 /src/css.js
parent8ad22a2b152f55b12385b126305383e2c5ba1994 (diff)
downloadjquery-58ed62ed12cb48d9224f699e86e197804ca5ece4.tar.gz
jquery-58ed62ed12cb48d9224f699e86e197804ca5ece4.zip
Effects: 1.8 Animation Rewrite - thanks @mikesherov and @gibson042
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/css.js b/src/css.js
index adfd4fda3..c3a6f7725 100644
--- a/src/css.js
+++ b/src/css.js
@@ -1,10 +1,12 @@
(function( jQuery ) {
+jQuery.cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
- rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
+ rnumsplit = /^([\-+]?(?:\d*\.)?\d+)(.*)$/i,
rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
rrelNum = /^([\-+])=([\-+.\de]+)/,
rmargin = /^margin/,
@@ -12,7 +14,7 @@ var ralpha = /alpha\([^)]*\)/i,
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
// order is important!
- cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+ cssExpand = jQuery.cssExpand,
cssPrefixes = [ "O", "Webkit", "Moz", "ms" ],
curCSS;
@@ -264,6 +266,13 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
};
}
+function setPositiveNumber( elem, value ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+ Math.max( 0, matches[ 1 ] ) + ( matches [ 2 ] || "px" )
+ : value;
+}
+
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
@@ -348,11 +357,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
}
},
- set: function( elem, value ) {
- return rnum.test( value ) ?
- value + "px" :
- value;
- }
+ set: setPositiveNumber
};
});
@@ -436,7 +441,6 @@ jQuery.each({
padding: "",
border: "Width"
}, function( prefix, suffix ) {
-
jQuery.cssHooks[ prefix + suffix ] = {
expand: function( value ) {
var i,
@@ -453,6 +457,10 @@ jQuery.each({
return expanded;
}
};
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
});
})( jQuery );