|
define( [ |
|
"../core", |
|
"../var/rcssNum" |
|
], function( jQuery, rcssNum ) { |
|
|
|
function adjustCSS( elem, prop, valueParts, tween ) { |
|
var adjusted, |
|
scale = 1, |
|
maxIterations = 20, |
|
currentValue = tween ? |
|
function() { return tween.cur(); } : |
|
function() { return jQuery.css( elem, prop, "" ); }, |
|
initial = currentValue(), |
|
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
|
|
|
|
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
|
rcssNum.exec( jQuery.css( elem, prop ) ); |
|
|
|
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
|
|
|
|
|
unit = unit || initialInUnit[ 3 ]; |
|
|
|
|
|
valueParts = valueParts || []; |
|
|
|
|
|
initialInUnit = +initial || 1; |
|
|
|
do { |
|
|
|
|
|
|
|
scale = scale || ".5"; |
|
|
|
|
|
initialInUnit = initialInUnit / scale; |
|
jQuery.style( elem, prop, initialInUnit + unit ); |
|
|
|
|
|
|
|
} while ( |
|
scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations |
|
); |
|
} |
|
|
|
if ( valueParts ) { |
|
initialInUnit = +initialInUnit || +initial || 0; |
|
|
|
|
|
adjusted = valueParts[ 1 ] ? |
|
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
|
+valueParts[ 2 ]; |
|
if ( tween ) { |
|
tween.unit = unit; |
|
tween.start = initialInUnit; |
|
tween.end = adjusted; |
|
} |
|
} |
|
return adjusted; |
|
} |
|
|
|
return adjustCSS; |
|
} ); |
|
|