Skip to content

Commit 1c26887

Browse files
committed
Removed Tween.startDelay because you can do it via TweenData.delay. Added new Duration calculation functions and TD caches.
1 parent 9470eed commit 1c26887

9 files changed

Lines changed: 28 additions & 45 deletions

File tree

v3/src/tween/ReservedProps.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = [
1515
'repeat',
1616
'repeatDelay',
1717
'startAt',
18-
'startDelay',
1918
'targets',
2019
'useFrames',
2120
'yoyo'

v3/src/tween/Tween.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ var Tween = function (manager, data)
1616
// If true then duration, delay, etc values are all frame totals
1717
this.useFrames = false;
1818

19-
// Time in ms/frames before the tween starts for the very first time
20-
// never used again once the tween has begun, even if it loops.
21-
this.startDelay = 0;
22-
2319
// Infinitely loop this tween?
24-
// When enabled it will play through ALL TweenDatas again (doesn't apply to just a single TD)
20+
// When enabled it will play through ALL TweenDatas again (use repeat to loop a single TD)
2521
this.loop = false;
2622

2723
// Time in ms/frames before the tween loops again if loop is true
@@ -30,7 +26,7 @@ var Tween = function (manager, data)
3026
// Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes)
3127
this.completeDelay = 0;
3228

33-
// Countdown timer (used by startDelay, loopDelay and completeDelay)
29+
// Countdown timer (used by loopDelay and completeDelay)
3430
this.countdown = 0;
3531

3632
this.state = TWEEN_CONST.PENDING_ADD;

v3/src/tween/TweenBuilder.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ var TweenBuilder = function (manager, config)
250250
tween.loop = GetBoolean(config, 'loop', false);
251251
tween.loopDelay = GetAdvancedValue(config, 'loopDelay', 0);
252252
tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0);
253-
tween.startDelay = GetAdvancedValue(config, 'startDelay', 0);
254253
tween.paused = GetBoolean(config, 'paused', false);
255254

256255
return tween;

v3/src/tween/TweenData.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ var TweenData = function (target, key, value, ease, delay, duration, yoyo, hold,
4747
// How many repeats are left to run?
4848
repeatCounter: 0,
4949

50-
// Value Data:
50+
// Ease Value Data:
5151

5252
start: 0,
5353
current: 0,
5454
end: 0,
5555
startCache: 0,
5656
endCache: 0,
5757

58+
// Time Durations
59+
t1: 0,
60+
t2: 0,
61+
5862
// LoadValue generation functions
5963
gen: {
6064
delay: delay,

v3/src/tween/components/CalcDuration.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,36 @@ var CalcDuration = function ()
44

55
var data = this.data;
66

7-
// Duration is derived from:
8-
// TweenData.duration
9-
// TweenData.delay
10-
// TweenData.hold
11-
// x TweenData.repeat
12-
137
for (var i = 0; i < this.totalData; i++)
148
{
159
var tweenData = data[i];
1610

17-
var total = tweenData.delay;
18-
19-
var single = tweenData.duration;
11+
// Set t1 (duration + hold + yoyo)
12+
tweenData.t1 = tweenData.duration + tweenData.hold;
2013

2114
if (tweenData.yoyo)
2215
{
23-
single *= 2;
16+
tweenData.t1 += tweenData.duration;
2417
}
2518

26-
single += tweenData.hold;
27-
28-
var totalRepeats = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat;
19+
// Set t2 (repeatDelay + duration + hold + yoyo)
20+
tweenData.t2 = tweenData.t1 + tweenData.repeatDelay;
2921

30-
single += single * totalRepeats;
22+
// Total Duration
23+
tweenData.totalDuration = tweenData.delay + tweenData.t1;
3124

32-
single += tweenData.repeatDelay * totalRepeats;
25+
tweenData.totalDuration += tweenData.t2 * (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat;
3326

34-
total += single;
35-
36-
if (total > max)
27+
if (tweenData.totalDuration > max)
3728
{
38-
max = total;
29+
max = tweenData.totalDuration;
3930
}
4031
}
4132

33+
// this.loop = false;
34+
// this.loopDelay = 0;
35+
// this.completeDelay = 0;
36+
4237
return max;
4338
};
4439

v3/src/tween/components/Init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var Init = function ()
1919
tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target);
2020
}
2121

22-
this.totalDuration = this.calcDuration();
22+
this.calcDuration();
2323

2424
console.log('Tween totalDuration', this.totalDuration);
2525

v3/src/tween/components/Play.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ var Play = function ()
1818
// Reset the TweenData
1919
this.resetTweenData();
2020

21-
if (this.startDelay > 0)
22-
{
23-
this.countdown = this.startDelay;
24-
this.state = TWEEN_CONST.START_DELAY;
25-
}
26-
else
27-
{
28-
this.state = TWEEN_CONST.ACTIVE;
29-
}
21+
this.state = TWEEN_CONST.ACTIVE;
3022
}
3123
};
3224

v3/src/tween/components/Update.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var Update = function (timestamp, delta)
3131
break;
3232

3333
case TWEEN_CONST.LOOP_DELAY:
34-
case TWEEN_CONST.START_DELAY:
3534

3635
this.countdown -= delta;
3736

v3/src/tween/const.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ var TWEEN_CONST = {
1616

1717
PENDING_ADD: 20,
1818
PAUSED: 21,
19-
START_DELAY: 22,
20-
LOOP_DELAY: 23,
21-
ACTIVE: 24,
22-
COMPLETE_DELAY: 25,
23-
PENDING_REMOVE: 26,
24-
REMOVED: 27
19+
LOOP_DELAY: 22,
20+
ACTIVE: 23,
21+
COMPLETE_DELAY: 24,
22+
PENDING_REMOVE: 25,
23+
REMOVED: 26
2524

2625
};
2726

0 commit comments

Comments
 (0)