Skip to content

Commit 17f65a5

Browse files
committed
Fixed Tween.loop functionality. Tween now resets properly as well.
1 parent bd4161e commit 17f65a5

7 files changed

Lines changed: 22 additions & 26 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '54a28910-4032-11e7-bbd7-b5cbb879efb2'
2+
build: '7912f7a0-4035-11e7-a0a7-d1432b20f467'
33
};
44
module.exports = CHECKSUM;

v3/src/tween/Tween.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ var Tween = function (manager, data)
1717
this.useFrames = false;
1818

1919
// Time in ms/frames before the tween starts for the very first time
20-
// (populated by stagger property, or directly) - never used again once the
21-
// tween has begun, even if it loops.
20+
// never used again once the tween has begun, even if it loops.
2221
this.startDelay = 0;
2322

2423
// Infinitely loop this tween?

v3/src/tween/TweenData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ var TweenData = function (target, key, value, ease, delay, duration, yoyo, yoyoD
5252
start: 0,
5353
current: 0,
5454
end: 0,
55+
startCache: 0,
56+
endCache: 0,
5557

5658
// LoadValue generation functions
5759
gen: {

v3/src/tween/TweenTarget.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

v3/src/tween/components/NextState.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ var NextState = function ()
44
{
55
if (this.loop)
66
{
7-
// leaves the state in PENDING_RENDER
8-
// this.setCurrentTweenData(prop, prop.list[0]);
9-
10-
// this.resetTargetsValue(prop.current);
7+
this.resetTweenData(true);
118

129
if (this.loopDelay > 0)
1310
{
1411
this.countdown = this.loopDelay;
1512
this.state = TWEEN_CONST.LOOP_DELAY;
1613
}
14+
else
15+
{
16+
this.state = TWEEN_CONST.ACTIVE;
17+
}
1718
}
1819
else if (this.completeDelay > 0)
1920
{

v3/src/tween/components/ResetTweenData.js

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

3-
var ResetTweenData = function ()
3+
var ResetTweenData = function (resetFromLoop)
44
{
55
var data = this.data;
66
var totalTargets = this.totalTargets;
@@ -22,7 +22,15 @@ var ResetTweenData = function ()
2222

2323
tweenData.repeatCounter = (tweenData.repeat === -1) ? Number.MAX_SAFE_INTEGER : tweenData.repeat;
2424

25-
if (tweenData.delay > 0)
25+
if (resetFromLoop)
26+
{
27+
tweenData.start = tweenData.startCache;
28+
tweenData.current = tweenData.start;
29+
tweenData.end = tweenData.endCache;
30+
31+
tweenData.state = TWEEN_CONST.PLAYING_FORWARD;
32+
}
33+
else if (tweenData.delay > 0)
2634
{
2735
tweenData.elapsed = tweenData.delay;
2836
tweenData.state = TWEEN_CONST.DELAY;

v3/src/tween/components/UpdateTweenData.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ var UpdateTweenData = function (tween, tweenData, delta)
174174
tweenData.current = tweenData.start;
175175
tweenData.end = tweenData.value(tweenData.start);
176176

177+
tweenData.startCache = tweenData.start;
178+
tweenData.endCache = tweenData.end;
179+
177180
tweenData.target[tweenData.key] = tweenData.current;
178181

179182
tweenData.state = TWEEN_CONST.PLAYING_FORWARD;

0 commit comments

Comments
 (0)