Skip to content

Commit ab83fd7

Browse files
committed
Tween.seek will no longer issue a console warning for 'Tween.seek duration too long', it's now up to you to check on the performance of tween seeking.
1 parent 3eb79f6 commit ab83fd7

1 file changed

Lines changed: 21 additions & 27 deletions

File tree

src/tweens/tween/Tween.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ var Tween = new Class({
310310

311311
/**
312312
* An object containing the different Tween callback functions.
313-
*
313+
*
314314
* You can either set these in the Tween config, or by calling the `Tween.setCallback` method.
315-
*
315+
*
316316
* `onActive` When the Tween is moved from the pending to the active list in the Tween Manager, even if playback paused.
317317
* `onStart` When the Tween starts playing after a delayed state. Will happen at the same time as `onActive` if it has no delay.
318318
* `onYoyo` When a TweenData starts a yoyo. This happens _after_ the `hold` delay expires, if set.
@@ -346,12 +346,12 @@ var Tween = new Class({
346346
this.callbackScope;
347347
},
348348

349-
/**
349+
/**
350350
* Returns the current value of the specified Tween Data.
351351
*
352352
* @method Phaser.Tweens.Tween#getValue
353353
* @since 3.0.0
354-
*
354+
*
355355
* @param {integer} [index=0] - The Tween Data to return the value from.
356356
*
357357
* @return {number} The value of the requested Tween Data.
@@ -436,9 +436,9 @@ var Tween = new Class({
436436

437437
/**
438438
* Updates the 'end' value of the given property across all matching targets.
439-
*
439+
*
440440
* Calling this does not adjust the duration of the tween, or the current progress.
441-
*
441+
*
442442
* You can optionally tell it to set the 'start' value to be the current value (before the change).
443443
*
444444
* @method Phaser.Tweens.Tween#updateTo
@@ -720,12 +720,12 @@ var Tween = new Class({
720720

721721
/**
722722
* Starts a Tween playing.
723-
*
723+
*
724724
* You only need to call this method if you have configured the tween to be paused on creation.
725-
*
725+
*
726726
* If the Tween is already playing, calling this method again will have no effect. If you wish to
727727
* restart the Tween, use `Tween.restart` instead.
728-
*
728+
*
729729
* Calling this method after the Tween has completed will start the Tween playing again from the start.
730730
* This is the same as calling `Tween.seek(0)` and then `Tween.play()`.
731731
*
@@ -877,16 +877,17 @@ var Tween = new Class({
877877

878878
/**
879879
* Seeks to a specific point in the Tween.
880-
*
881-
* **Note:** You cannot seek a Tween that repeats or loops forever, or that has an unusually long total duration.
882-
*
880+
*
881+
* **Note:** Be careful when seeking a Tween that repeats or loops forever,
882+
* or that has an unusually long total duration, as it's possible to hang the browser.
883+
*
883884
* The given position is a value between 0 and 1 which represents how far through the Tween to seek to.
884885
* A value of 0.5 would seek to half-way through the Tween, where-as a value of zero would seek to the start.
885-
*
886+
*
886887
* Note that the seek takes the entire duration of the Tween into account, including delays, loops and repeats.
887888
* For example, a Tween that lasts for 2 seconds, but that loops 3 times, would have a total duration of 6 seconds,
888889
* so seeking to 0.5 would seek to 3 seconds into the Tween, as that's half-way through its _entire_ duration.
889-
*
890+
*
890891
* Seeking works by resetting the Tween to its initial values and then iterating through the Tween at `delta`
891892
* jumps per step. The longer the Tween, the longer this can take.
892893
*
@@ -902,13 +903,6 @@ var Tween = new Class({
902903
{
903904
if (delta === undefined) { delta = 16.6; }
904905

905-
if (this.totalDuration >= 3600000)
906-
{
907-
console.warn('Tween.seek duration too long');
908-
909-
return this;
910-
}
911-
912906
if (this.state === TWEEN_CONST.REMOVED)
913907
{
914908
this.makeActive();
@@ -987,11 +981,11 @@ var Tween = new Class({
987981

988982
/**
989983
* Sets an event based callback to be invoked during playback.
990-
*
984+
*
991985
* Calling this method will replace a previously set callback for the given type, if any exists.
992-
*
986+
*
993987
* The types available are:
994-
*
988+
*
995989
* `onActive` When the Tween is moved from the pending to the active list in the Tween Manager, even if playback paused.
996990
* `onStart` When the Tween starts playing after a delayed state. Will happen at the same time as `onActive` if it has no delay.
997991
* `onYoyo` When a TweenData starts a yoyo. This happens _after_ the `hold` delay expires, if set.
@@ -1056,7 +1050,7 @@ var Tween = new Class({
10561050
/**
10571051
* Immediately removes this Tween from the TweenManager and all of its internal arrays,
10581052
* no matter what stage it as it. Then sets the tween state to `REMOVED`.
1059-
*
1053+
*
10601054
* You should dispose of your reference to this tween after calling this method, to
10611055
* free it from memory.
10621056
*
@@ -1159,7 +1153,7 @@ var Tween = new Class({
11591153
if (!this.hasStarted && !this.isSeeking)
11601154
{
11611155
this.startDelay -= delta;
1162-
1156+
11631157
if (this.startDelay <= 0)
11641158
{
11651159
this.hasStarted = true;
@@ -1272,7 +1266,7 @@ var Tween = new Class({
12721266
if (callback)
12731267
{
12741268
callback.params[1] = this.targets;
1275-
1269+
12761270
callback.func.apply(callback.scope, callback.params);
12771271
}
12781272
}

0 commit comments

Comments
 (0)