4 ], function( jQuery, rcssNum ) {
8 function adjustCSS( elem, prop, valueParts, tween ) {
11 currentValue = tween ?
16 return jQuery.css( elem, prop, "" );
18 initial = currentValue(),
19 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
21 // Starting value computation is required for potential unit mismatches
22 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
23 rcssNum.exec( jQuery.css( elem, prop ) );
25 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
27 // Support: Firefox <=54
28 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
29 initial = initial / 2;
31 // Trust units reported by jQuery.css
32 unit = unit || initialInUnit[ 3 ];
34 // Iteratively approximate from a nonzero starting point
35 initialInUnit = +initial || 1;
37 while ( maxIterations-- ) {
39 // Evaluate and update our best guess (doubling guesses that zero out).
40 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
41 jQuery.style( elem, prop, initialInUnit + unit );
42 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
45 initialInUnit = initialInUnit / scale;
49 initialInUnit = initialInUnit * 2;
50 jQuery.style( elem, prop, initialInUnit + unit );
52 // Make sure we update the tween properties later on
53 valueParts = valueParts || [];
57 initialInUnit = +initialInUnit || +initial || 0;
59 // Apply relative offset (+=/-=) if specified
60 adjusted = valueParts[ 1 ] ?
61 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
65 tween.start = initialInUnit;