Skip to content

Commit 4bd7a40

Browse files
author
hardalias
committed
Fixes neverending tween when duration set to zero
* Passing a value of zero as the value of duration causes the calculations performed in Tween#update to divide by zero when calculating the next step for the tween. This causes the tweened property value to be set to NaN having undesireable results and also, causes the tween to never end since the ending criteria are never met.
1 parent 645723f commit 4bd7a40

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/tween/Tween.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Phaser.Tween.prototype = {
183183
*/
184184
to: function (properties, duration, ease, autoStart, delay, repeat, yoyo) {
185185

186-
if (typeof duration === 'undefined') { duration = 1000; }
186+
if (typeof duration === 'undefined' || duration <= 0) { duration = 1000; }
187187
if (typeof ease === 'undefined') { ease = Phaser.Easing.Default; }
188188
if (typeof autoStart === 'undefined') { autoStart = false; }
189189
if (typeof delay === 'undefined') { delay = 0; }

0 commit comments

Comments
 (0)