@@ -6,8 +6,7 @@ define( [
66"use strict" ;
77
88function adjustCSS ( elem , prop , valueParts , tween ) {
9- var adjusted ,
10- scale = 1 ,
9+ var adjusted , scale ,
1110 maxIterations = 20 ,
1211 currentValue = tween ?
1312 function ( ) {
@@ -25,30 +24,33 @@ function adjustCSS( elem, prop, valueParts, tween ) {
2524
2625 if ( initialInUnit && initialInUnit [ 3 ] !== unit ) {
2726
27+ // Support: Firefox <=54
28+ // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
29+ initial = initial / 2 ;
30+
2831 // Trust units reported by jQuery.css
2932 unit = unit || initialInUnit [ 3 ] ;
3033
31- // Make sure we update the tween properties later on
32- valueParts = valueParts || [ ] ;
33-
3434 // Iteratively approximate from a nonzero starting point
3535 initialInUnit = + initial || 1 ;
3636
37- do {
38-
39- // If previous iteration zeroed out, double until we get *something*.
40- // Use string for doubling so we don't accidentally see scale as unchanged below
41- scale = scale || ".5" ;
37+ while ( maxIterations -- ) {
4238
43- // Adjust and apply
44- initialInUnit = initialInUnit / scale ;
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).
4541 jQuery . style ( elem , prop , initialInUnit + unit ) ;
42+ if ( ( 1 - scale ) * ( 1 - ( scale = currentValue ( ) / initial || 0.5 ) ) <= 0 ) {
43+ maxIterations = 0 ;
44+ }
45+ initialInUnit = initialInUnit / scale ;
46+
47+ }
4648
47- // Update scale, tolerating zero or NaN from tween.cur()
48- // Break the loop if scale is unchanged or perfect, or if we've just had enough.
49- } while (
50- scale !== ( scale = currentValue ( ) / initial ) && scale !== 1 && -- maxIterations
51- ) ;
49+ initialInUnit = initialInUnit * 2 ;
50+ jQuery . style ( elem , prop , initialInUnit + unit ) ;
51+
52+ // Make sure we update the tween properties later on
53+ valueParts = valueParts || [ ] ;
5254 }
5355
5456 if ( valueParts ) {
0 commit comments