|
|
@@ -6,8 +6,7 @@ define( [ |
|
|
"use strict";
|
|
|
|
|
|
function adjustCSS( elem, prop, valueParts, tween ) {
|
|
|
- var adjusted,
|
|
|
- scale = 1,
|
|
|
+ var adjusted, scale,
|
|
|
maxIterations = 20,
|
|
|
currentValue = tween ?
|
|
|
function() {
|
|
|
@@ -25,30 +24,33 @@ function adjustCSS( elem, prop, valueParts, tween ) { |
|
|
|
|
|
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
|
|
|
|
|
|
+ // Support: Firefox <=54
|
|
|
+ // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
|
|
|
+ initial = initial / 2;
|
|
|
+
|
|
|
// Trust units reported by jQuery.css
|
|
|
unit = unit || initialInUnit[ 3 ];
|
|
|
|
|
|
- // Make sure we update the tween properties later on
|
|
|
- valueParts = valueParts || [];
|
|
|
-
|
|
|
// Iteratively approximate from a nonzero starting point
|
|
|
initialInUnit = +initial || 1;
|
|
|
|
|
|
- do {
|
|
|
-
|
|
|
- // If previous iteration zeroed out, double until we get *something*.
|
|
|
- // Use string for doubling so we don't accidentally see scale as unchanged below
|
|
|
- scale = scale || ".5";
|
|
|
+ while ( maxIterations-- ) {
|
|
|
|
|
|
- // Adjust and apply
|
|
|
- initialInUnit = initialInUnit / scale;
|
|
|
+ // Evaluate and update our best guess (doubling guesses that zero out).
|
|
|
+ // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
|
|
|
jQuery.style( elem, prop, initialInUnit + unit );
|
|
|
+ if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
|
|
|
+ maxIterations = 0;
|
|
|
+ }
|
|
|
+ initialInUnit = initialInUnit / scale;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- // Update scale, tolerating zero or NaN from tween.cur()
|
|
|
- // Break the loop if scale is unchanged or perfect, or if we've just had enough.
|
|
|
- } while (
|
|
|
- scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
|
|
|
- );
|
|
|
+ initialInUnit = initialInUnit * 2;
|
|
|
+ jQuery.style( elem, prop, initialInUnit + unit );
|
|
|
+
|
|
|
+ // Make sure we update the tween properties later on
|
|
|
+ valueParts = valueParts || [];
|
|
|
}
|
|
|
|
|
|
if ( valueParts ) {
|
|
|
|
0 comments on commit
692f9d4