| 4740 | |
| 4741 | |
| 4742 | function adjustCSS( elem, prop, valueParts, tween ) { |
| 4743 | var adjusted, scale, |
| 4744 | maxIterations = 20, |
| 4745 | currentValue = tween ? |
| 4746 | function() { |
| 4747 | return tween.cur(); |
| 4748 | } : |
| 4749 | function() { |
| 4750 | return jQuery.css( elem, prop, "" ); |
| 4751 | }, |
| 4752 | initial = currentValue(), |
| 4753 | unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
| 4754 | |
| 4755 | // Starting value computation is required for potential unit mismatches |
| 4756 | initialInUnit = elem.nodeType && |
| 4757 | ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
| 4758 | rcssNum.exec( jQuery.css( elem, prop ) ); |
| 4759 | |
| 4760 | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
| 4761 | |
| 4762 | // Support: Firefox <=54 |
| 4763 | // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) |
| 4764 | initial = initial / 2; |
| 4765 | |
| 4766 | // Trust units reported by jQuery.css |
| 4767 | unit = unit || initialInUnit[ 3 ]; |
| 4768 | |
| 4769 | // Iteratively approximate from a nonzero starting point |
| 4770 | initialInUnit = +initial || 1; |
| 4771 | |
| 4772 | while ( maxIterations-- ) { |
| 4773 | |
| 4774 | // Evaluate and update our best guess (doubling guesses that zero out). |
| 4775 | // Finish if the scale equals or crosses 1 (making the old*new product non-positive). |
| 4776 | jQuery.style( elem, prop, initialInUnit + unit ); |
| 4777 | if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { |
| 4778 | maxIterations = 0; |
| 4779 | } |
| 4780 | initialInUnit = initialInUnit / scale; |
| 4781 | |
| 4782 | } |
| 4783 | |
| 4784 | initialInUnit = initialInUnit * 2; |
| 4785 | jQuery.style( elem, prop, initialInUnit + unit ); |
| 4786 | |
| 4787 | // Make sure we update the tween properties later on |
| 4788 | valueParts = valueParts || []; |
| 4789 | } |
| 4790 | |
| 4791 | if ( valueParts ) { |
| 4792 | initialInUnit = +initialInUnit || +initial || 0; |
| 4793 | |
| 4794 | // Apply relative offset (+=/-=) if specified |
| 4795 | adjusted = valueParts[ 1 ] ? |
| 4796 | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
| 4797 | +valueParts[ 2 ]; |
| 4798 | if ( tween ) { |
| 4799 | tween.unit = unit; |