| 1 | define( [
|
| 2 | "../core",
|
| 3 | "../var/rcssNum"
|
| 4 | ], function( jQuery, rcssNum ) {
|
| 5 |
|
| 6 | "use strict";
|
| 7 |
|
| 8 | function adjustCSS( elem, prop, valueParts, tween ) {
|
| 9 | var adjusted, scale,
|
| 10 | maxIterations = 20,
|
| 11 | currentValue = tween ?
|
| 12 | function() {
|
| 13 | return tween.cur();
|
| 14 | } :
|
| 15 | function() {
|
| 16 | return jQuery.css( elem, prop, "" );
|
| 17 | },
|
| 18 | initial = currentValue(),
|
| 19 | unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
| 20 |
|
| 21 |
|
| 22 | initialInUnit = elem.nodeType &&
|
| 23 | ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
|
| 24 | rcssNum.exec( jQuery.css( elem, prop ) );
|
| 25 |
|
| 26 | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 | initial = initial / 2;
|
| 31 |
|
| 32 |
|
| 33 | unit = unit || initialInUnit[ 3 ];
|
| 34 |
|
| 35 |
|
| 36 | initialInUnit = +initial || 1;
|
| 37 |
|
| 38 | while ( maxIterations-- ) {
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 | jQuery.style( elem, prop, initialInUnit + unit );
|
| 43 | if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
|
| 44 | maxIterations = 0;
|
| 45 | }
|
| 46 | initialInUnit = initialInUnit / scale;
|
| 47 |
|
| 48 | }
|
| 49 |
|
| 50 | initialInUnit = initialInUnit * 2;
|
| 51 | jQuery.style( elem, prop, initialInUnit + unit );
|
| 52 |
|
| 53 |
|
| 54 | valueParts = valueParts || [];
|
| 55 | }
|
| 56 |
|
| 57 | if ( valueParts ) {
|
| 58 | initialInUnit = +initialInUnit || +initial || 0;
|
| 59 |
|
| 60 |
|
| 61 | adjusted = valueParts[ 1 ] ?
|
| 62 | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
|
| 63 | +valueParts[ 2 ];
|
| 64 | if ( tween ) {
|
| 65 | tween.unit = unit;
|
| 66 | tween.start = initialInUnit;
|
| 67 | tween.end = adjusted;
|
| 68 | }
|
| 69 | }
|
| 70 | return adjusted;
|
| 71 | }
|
| 72 |
|
| 73 | return adjustCSS;
|
| 74 | } );
|