Skip to content

Commit fb8b428

Browse files
committed
Added hasTarget method. Also you cannot add a Tween into a Timeline already playing.
1 parent 1de0242 commit fb8b428

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

v3/src/tween/manager/TweenManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ var TweenManager = new Class({
3939
{
4040
var timeline = TimelineBuilder(this, config);
4141

42-
this._add.push(timeline);
42+
if (!timeline.paused)
43+
{
44+
this._add.push(timeline);
4345

44-
this._toProcess++;
46+
this._toProcess++;
47+
}
4548

4649
return timeline;
4750
},

v3/src/tween/timeline/Timeline.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ var Timeline = new Class({
103103

104104
queue: function (tween)
105105
{
106-
tween.parent = this;
107-
tween.parentIsTimeline = true;
106+
if (!this.isPlaying())
107+
{
108+
tween.parent = this;
109+
tween.parentIsTimeline = true;
108110

109-
this.data.push(tween);
111+
this.data.push(tween);
110112

111-
this.totalData = this.data.length;
113+
this.totalData = this.data.length;
114+
}
112115

113116
return this;
114117
},
@@ -467,13 +470,25 @@ var Timeline = new Class({
467470
return this;
468471
},
469472

470-
hasTarget: function ()
473+
hasTarget: function (target)
471474
{
472-
475+
for (var i = 0; i < this.data.length; i++)
476+
{
477+
if (this.data[i].hasTarget(target))
478+
{
479+
return true;
480+
}
481+
}
482+
483+
return false;
473484
},
474485

475486
destroy: function ()
476487
{
488+
for (var i = 0; i < this.data.length; i++)
489+
{
490+
this.data[i].destroy();
491+
}
477492

478493
}
479494
});

0 commit comments

Comments
 (0)