aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2012-09-15 11:57:01 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-09-15 13:10:37 -0400
commite755c194161e1dc6793cbb690ba8334dad560c8f (patch)
tree5a6156f723c77b65117aff0c65fbe23d8a920cf2 /src/effects.js
parent560c178c82da95b2f88ae518552463d87fe5adbf (diff)
downloadjquery-e755c194161e1dc6793cbb690ba8334dad560c8f.tar.gz
jquery-e755c194161e1dc6793cbb690ba8334dad560c8f.zip
Fix #12447: Ensure starting-point calc takes finite time. Close gh-922.
Diffstat (limited to 'src/effects.js')
-rw-r--r--src/effects.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/effects.js b/src/effects.js
index 8752838fb..3118da407 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -5,12 +5,13 @@ var fxNow, timerId,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [function( prop, value ) {
- var end, unit, prevScale,
+ var end, unit,
tween = this.createTween( prop, value ),
parts = rfxnum.exec( value ),
target = tween.cur(),
start = +target || 0,
- scale = 1;
+ scale = 1,
+ maxIterations = 20;
if ( parts ) {
end = +parts[2];
@@ -26,17 +27,15 @@ var fxNow, timerId,
do {
// If previous iteration zeroed out, double until we get *something*
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
- prevScale = scale = scale || ".5";
+ scale = scale || ".5";
// Adjust and apply
start = start / scale;
jQuery.style( tween.elem, prop, start + unit );
- // Update scale, tolerating zeroes from tween.cur()
- scale = tween.cur() / target;
-
- // Stop looping if we've hit the mark or scale is unchanged
- } while ( scale !== 1 && scale !== prevScale );
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
}
tween.unit = unit;