Skip to content

Commit e755c19

Browse files
gibson042dmethvin
authored andcommitted
Fix #12447: Ensure starting-point calc takes finite time. Close jquerygh-922.
1 parent 560c178 commit e755c19

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/effects.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ var fxNow, timerId,
55
animationPrefilters = [ defaultPrefilter ],
66
tweeners = {
77
"*": [function( prop, value ) {
8-
var end, unit, prevScale,
8+
var end, unit,
99
tween = this.createTween( prop, value ),
1010
parts = rfxnum.exec( value ),
1111
target = tween.cur(),
1212
start = +target || 0,
13-
scale = 1;
13+
scale = 1,
14+
maxIterations = 20;
1415

1516
if ( parts ) {
1617
end = +parts[2];
@@ -26,17 +27,15 @@ var fxNow, timerId,
2627
do {
2728
// If previous iteration zeroed out, double until we get *something*
2829
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
29-
prevScale = scale = scale || ".5";
30+
scale = scale || ".5";
3031

3132
// Adjust and apply
3233
start = start / scale;
3334
jQuery.style( tween.elem, prop, start + unit );
3435

35-
// Update scale, tolerating zeroes from tween.cur()
36-
scale = tween.cur() / target;
37-
38-
// Stop looping if we've hit the mark or scale is unchanged
39-
} while ( scale !== 1 && scale !== prevScale );
36+
// Update scale, tolerating zero or NaN from tween.cur()
37+
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough
38+
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
4039
}
4140

4241
tween.unit = unit;

0 commit comments

Comments
 (0)