Skip to content

Commit d1468bb

Browse files
committed
Preparing for totalDuration work.
1 parent 22bc09d commit d1468bb

4 files changed

Lines changed: 53 additions & 16 deletions

File tree

v3/src/tween/Tween.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
var TWEEN_CONST = require('./const');
22

3-
// A Tween is responsible for tweening one property of one target.
4-
// If a target has many properties being tweened, then each unique property will be its own Tween object.
5-
// This allows us to have differing ease, duration and associated events per property.
6-
// A Tween contains TweenData objects (at least one). It can contain more than one TweenData,
7-
// in which case they play out like a nested timeline, all impacting just the one target property.
8-
93
var Tween = function (manager, targets, tweenData)
104
{
115
this.manager = manager;
@@ -16,6 +10,7 @@ var Tween = function (manager, targets, tweenData)
1610
// targets array size doesn't change, so we can cache the length
1711
this.totalTargets = targets.length;
1812

13+
// The property data and TweenData lists
1914
this.data = tweenData;
2015

2116
// An object with a property matching those being tweened by this Tween.
@@ -37,20 +32,20 @@ var Tween = function (manager, targets, tweenData)
3732

3833
// Time in ms/frames before the tween starts for the very first time
3934
// (populated by stagger property, or directly) - never used again once the
40-
// tween has begun.
35+
// tween has begun, even if it loops.
4136
this.startDelay = 0;
4237

43-
// infinitely loop this tween? Maybe a string? 'alternate', 'reverse', etc
44-
// When enabled it will play through
38+
// Infinitely loop this tween?
39+
// When enabled it will play through ALL TweenDatas again (doesn't apply to just a single TD)
4540
this.loop = false;
4641

4742
// Time in ms/frames before the tween loops again if loop is true
4843
this.loopDelay = 0;
4944

50-
// Time in ms/frames before the 'onComplete' event fires
45+
// Time in ms/frames before the 'onComplete' event fires.
5146
this.completeDelay = 0;
5247

53-
// delta countdown timer (used by startDelay and loopDelay)
48+
// Countdown timer (used by startDelay, loopDelay and completeDelay)
5449
this.countdown = 0;
5550

5651
this.state = TWEEN_CONST.PENDING_ADD;

v3/src/tween/TweenBuilder.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ var TweenBuilder = function (manager, config)
217217
GetValue(value, 'yoyo', yoyo)
218218
);
219219

220+
// Calculate total duration
221+
222+
// Duration is derived from:
223+
// TweenData.duration
224+
// TweenData.delay
225+
// TweenData.hold
226+
// x TweenData.repeat
227+
228+
// var totalDuration = 0;
229+
230+
// var playThruDuration = tweenData.duration * tweenData.repeat;
231+
232+
// totalDuration
233+
// tweenData.totalDuration =
234+
220235
tweenData.prev = prev;
221236

222237
if (prev)

v3/src/tween/TweenData.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ var TweenData = function (key, value, ease, delay, duration, hold, repeat, repea
1414
// duration of the tween in ms/frames, excludes time for yoyo or repeats
1515
duration: duration,
1616

17-
// return the tween back to its start position again?
17+
// The total calculated duration of this TweenData (based on duration, repeat, delay, hold, yoyo)
18+
totalDuration: 0,
19+
20+
// Cause the tween to alternate back and forth on each *repeat*. Has no effect unless repeat > 0.
1821
yoyo: yoyo,
1922

20-
// number of times to repeat the tween
23+
// Number of times to repeat the tween.
2124
repeat: repeat,
2225

23-
// time in ms/frames before tween will start
26+
// Time in ms/frames before tween will start.
2427
delay: delay,
2528

26-
// time in ms/frames the tween will remain in its end state before either yoyo, repeat or complete
29+
// Time in ms/frames the tween will remain in its end state before repeat or complete.
2730
hold: hold,
2831

29-
// time in ms/frames before repeat will start
32+
// Time in ms/frames before repeat will start
3033
repeatDelay: repeatDelay,
3134

3235
// Changes the property to be this value before starting the tween
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var CalcDuration = function ()
2+
{
3+
var total = 0;
4+
5+
for (var key in this.data)
6+
{
7+
var prop = this.data[key];
8+
9+
for (var i = 0; i < prop.list.length; i++)
10+
{
11+
// var tweenData = prop.list[i];
12+
13+
// Duration is derived from:
14+
// TweenData.duration
15+
// TweenData.delay
16+
// TweenData.hold
17+
// x TweenData.repeat
18+
}
19+
}
20+
21+
return total;
22+
};
23+
24+
module.exports = CalcDuration;

0 commit comments

Comments
 (0)