Skip to content

Commit 206f6b1

Browse files
committed
Added Tween.restart and stopped the manager adding the same tween twice
1 parent a2d96f5 commit 206f6b1

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

v3/src/tween/manager/TweenManager.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ var TweenManager = new Class({
160160

161161
makeActive: function (tween)
162162
{
163+
if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1)
164+
{
165+
return;
166+
}
167+
163168
var idx = this._pending.indexOf(tween);
164169

165170
if (idx !== -1)
@@ -172,6 +177,8 @@ var TweenManager = new Class({
172177
tween.state = TWEEN_CONST.PENDING_ADD;
173178

174179
this._toProcess++;
180+
181+
return this;
175182
},
176183

177184
setGlobalTimeScale: require('./components/SetGlobalTimeScale'),

v3/src/tween/tween/Tween.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ var Tween = new Class({
131131
return this;
132132
},
133133

134+
restart: function ()
135+
{
136+
this.stop();
137+
this.play();
138+
},
139+
134140
calcDuration: require('./components/CalcDuration'),
135141
init: require('./components/Init'),
136142
nextState: require('./components/NextState'),

v3/src/tween/tween/components/Play.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var Play = function (resetFromTimeline)
1010
{
1111
this.init();
1212
this.parent.makeActive(this);
13+
resetFromTimeline = true;
1314
}
1415

1516
var onStart = this.callbacks.onStart;
@@ -46,7 +47,7 @@ var Play = function (resetFromTimeline)
4647
}
4748
else
4849
{
49-
this.resetTweenData(false);
50+
this.resetTweenData(resetFromTimeline);
5051

5152
this.state = TWEEN_CONST.ACTIVE;
5253

0 commit comments

Comments
 (0)