Skip to content

Commit 46b56c4

Browse files
committed
All changes to Tween.state are now set _before_ any events or callbacks, allowing you to modify the state of the Tween in those handlers
1 parent 9582a21 commit 46b56c4

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* `Tween.onRepeat` will now be invoked _after_ the `repeatDelay` has expired, if any was set.
2424
* `easeParams` would be ignored for tweens that _didn't_ use a string for the ease function name. Fix #3826 (thanks @SBCGames)
2525
* You can now specify `easeParams` for any custom easing function you wish to use. Fix #3826 (thanks @SBCGames)
26+
* All changes to `Tween.state` are now set _before_ any events or callbacks, allowing you to modify the state of the Tween in those handlers (thanks @Cudabear)
2627

2728
### New Features
2829

src/tweens/tween/Tween.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ var Tween = new Class({
654654
}
655655
else
656656
{
657+
this.state = TWEEN_CONST.ACTIVE;
658+
657659
this.emit(Events.TWEEN_LOOP, this, this.targets);
658660

659661
var onLoop = this.callbacks.onLoop;
@@ -664,8 +666,6 @@ var Tween = new Class({
664666

665667
onLoop.func.apply(onLoop.scope, onLoop.params);
666668
}
667-
668-
this.state = TWEEN_CONST.ACTIVE;
669669
}
670670
}
671671
else if (this.completeDelay > 0)
@@ -675,6 +675,8 @@ var Tween = new Class({
675675
}
676676
else
677677
{
678+
this.state = TWEEN_CONST.PENDING_REMOVE;
679+
678680
this.emit(Events.TWEEN_COMPLETE, this, this.targets);
679681

680682
var onComplete = this.callbacks.onComplete;
@@ -685,8 +687,6 @@ var Tween = new Class({
685687

686688
onComplete.func.apply(onComplete.scope, onComplete.params);
687689
}
688-
689-
this.state = TWEEN_CONST.PENDING_REMOVE;
690690
}
691691
},
692692

@@ -1013,6 +1013,8 @@ var Tween = new Class({
10131013
}
10141014
else
10151015
{
1016+
this.state = TWEEN_CONST.PENDING_REMOVE;
1017+
10161018
this.emit(Events.TWEEN_COMPLETE, this, this.targets);
10171019

10181020
var onComplete = this.callbacks.onComplete;
@@ -1023,8 +1025,6 @@ var Tween = new Class({
10231025

10241026
onComplete.func.apply(onComplete.scope, onComplete.params);
10251027
}
1026-
1027-
this.state = TWEEN_CONST.PENDING_REMOVE;
10281028
}
10291029

10301030
return this;
@@ -1178,6 +1178,8 @@ var Tween = new Class({
11781178

11791179
if (this.countdown <= 0)
11801180
{
1181+
this.state = TWEEN_CONST.ACTIVE;
1182+
11811183
this.emit(Events.TWEEN_LOOP, this, this.targets);
11821184

11831185
var onLoop = this.callbacks.onLoop;
@@ -1188,8 +1190,6 @@ var Tween = new Class({
11881190

11891191
onLoop.func.apply(onLoop.scope, onLoop.params);
11901192
}
1191-
1192-
this.state = TWEEN_CONST.ACTIVE;
11931193
}
11941194

11951195
break;
@@ -1211,6 +1211,8 @@ var Tween = new Class({
12111211

12121212
if (this.countdown <= 0)
12131213
{
1214+
this.state = TWEEN_CONST.PENDING_REMOVE;
1215+
12141216
this.emit(Events.TWEEN_COMPLETE, this, this.targets);
12151217

12161218
var onComplete = this.callbacks.onComplete;
@@ -1219,8 +1221,6 @@ var Tween = new Class({
12191221
{
12201222
onComplete.func.apply(onComplete.scope, onComplete.params);
12211223
}
1222-
1223-
this.state = TWEEN_CONST.PENDING_REMOVE;
12241224
}
12251225

12261226
break;

0 commit comments

Comments
 (0)