( elem, prop, valueParts, tween )
| 4130 | } |
| 4131 | |
| 4132 | function adjustCSS( elem, prop, valueParts, tween ) { |
| 4133 | var adjusted, scale, |
| 4134 | maxIterations = 20, |
| 4135 | currentValue = tween ? |
| 4136 | function() { |
| 4137 | return tween.cur(); |
| 4138 | } : |
| 4139 | function() { |
| 4140 | return jQuery.css( elem, prop, "" ); |
| 4141 | }, |
| 4142 | initial = currentValue(), |
| 4143 | unit = valueParts && valueParts[ 3 ] || ( isAutoPx( prop ) ? "px" : "" ), |
| 4144 | |
| 4145 | // Starting value computation is required for potential unit mismatches |
| 4146 | initialInUnit = elem.nodeType && |
| 4147 | ( !isAutoPx( prop ) || unit !== "px" && +initial ) && |
| 4148 | rcssNum.exec( jQuery.css( elem, prop ) ); |
| 4149 | |
| 4150 | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
| 4151 | |
| 4152 | // Support: Firefox <=54 - 66+ |
| 4153 | // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) |
| 4154 | initial = initial / 2; |
| 4155 | |
| 4156 | // Trust units reported by jQuery.css |
| 4157 | unit = unit || initialInUnit[ 3 ]; |
| 4158 | |
| 4159 | // Iteratively approximate from a nonzero starting point |
| 4160 | initialInUnit = +initial || 1; |
| 4161 | |
| 4162 | while ( maxIterations-- ) { |
| 4163 | |
| 4164 | // Evaluate and update our best guess (doubling guesses that zero out). |
| 4165 | // Finish if the scale equals or crosses 1 (making the old*new product non-positive). |
| 4166 | jQuery.style( elem, prop, initialInUnit + unit ); |
| 4167 | if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { |
| 4168 | maxIterations = 0; |
| 4169 | } |
| 4170 | initialInUnit = initialInUnit / scale; |
| 4171 | |
| 4172 | } |
| 4173 | |
| 4174 | initialInUnit = initialInUnit * 2; |
| 4175 | jQuery.style( elem, prop, initialInUnit + unit ); |
| 4176 | |
| 4177 | // Make sure we update the tween properties later on |
| 4178 | valueParts = valueParts || []; |
| 4179 | } |
| 4180 | |
| 4181 | if ( valueParts ) { |
| 4182 | initialInUnit = +initialInUnit || +initial || 0; |
| 4183 | |
| 4184 | // Apply relative offset (+=/-=) if specified |
| 4185 | adjusted = valueParts[ 1 ] ? |
| 4186 | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
| 4187 | +valueParts[ 2 ]; |
| 4188 | if ( tween ) { |
| 4189 | tween.unit = unit; |
no test coverage detected