Skip to content

Commit ffc7635

Browse files
committed
Merge pull request #261 from rjwright/GroupChildInit
Group child initialization
2 parents bcc93c9 + e570ec5 commit ffc7635

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

src/animation-constructor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
// TODO: Call into this less frequently.
100100
scope.Player.prototype._updateChildren = function() {
101-
if (this.startTime === null || !this.source || !this._isGroup)
101+
if (this.paused || !this.source || !this._isGroup)
102102
return;
103103
var offset = this.source._timing.delay;
104104
for (var i = 0; i < this.source.children.length; i++) {
@@ -107,14 +107,19 @@
107107

108108
if (i >= this._childPlayers.length) {
109109
childPlayer = window.document.timeline.play(child);
110-
child.player = this.source.player;
111110
this._childPlayers.push(childPlayer);
112111
} else {
113112
childPlayer = this._childPlayers[i];
114113
}
114+
child.player = this.source.player;
115115

116116
if (childPlayer.startTime != this.startTime + offset) {
117-
childPlayer.startTime = this.startTime + offset;
117+
if (this.startTime === null) {
118+
childPlayer.currentTime = this.source.player.currentTime - offset;
119+
childPlayer._startTime = null;
120+
} else {
121+
childPlayer.startTime = this.startTime + offset;
122+
}
118123
childPlayer._updateChildren();
119124
}
120125

src/group-constructors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
player._player._wrapper = player;
7676
player._isGroup = true;
7777
scope.awaitStartTime(player);
78+
player._updateChildren();
7879
};
7980

8081

test/js/group-player.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ suite('group-player', function() {
183183
test('playing an animationGroup works as expected', function() {
184184
tick(90);
185185
var p = document.timeline.play(simpleAnimationGroup());
186-
checkTimes(p, [null, 0], []);
186+
checkTimes(p, [null, 0], [[null, 0], [null, 0], [null, 0]]);
187187
tick(100);
188188
checkTimes(p, [100, 0], [[100, 0], [100, 0], [100, 0]]);
189189
tick(300);
@@ -547,6 +547,35 @@ suite('group-player', function() {
547547
checkTimes(player, [101, 599], [[101, 500], [601, 99]], 't = 700');
548548
});
549549

550+
test('pausing before tick works as expected with a simple AnimationSequence', function() {
551+
var player = document.timeline.play(this.seqSimple_source);
552+
checkTimes(player, [null, 0], [[null, 0], [null, -500]], 't = 0');
553+
554+
player.pause();
555+
checkTimes(player, [null, null], [[null, null], [null, null]], 't = 0');
556+
557+
tick(10);
558+
checkTimes(player, [null, 0], [[null, 0], [null, -500]], 't = 10');
559+
});
560+
561+
test('pausing and seeking before tick works as expected with a simple AnimationSequence', function() {
562+
var player = document.timeline.play(this.seqSimple_source);
563+
player.pause();
564+
565+
player.currentTime = 0;
566+
checkTimes(player, [null, 0], [[null, 0], [null, -500]], 't = 10');
567+
568+
player.currentTime = 250;
569+
checkTimes(player, [null, 250], [[null, 250], [null, -250]], 't = 10');
570+
571+
player.currentTime = 500;
572+
checkTimes(player, [null, 500], [[null, 500], [null, 0]], 't = 10');
573+
574+
// FIXME: Expectation should be [null, 1000], [[null, 500], [null, 500]].
575+
player.currentTime = 1000;
576+
checkTimes(player, [null, 1000], [[null, 1000], [null, 500]], 't = 10');
577+
});
578+
550579
test('pausing works as expected with an AnimationSequence inside an AnimationSequence', function() {
551580
var player = document.timeline.play(this.seqWithSeq_source);
552581
tick(0);

0 commit comments

Comments
 (0)