1 // Copyright 2014 Google Inc. All rights reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 (function(shared, scope, testing) {
17 function constructor(children, timingInput) {
18 this.children = children || [];
19 this._timing = shared.normalizeTimingInput(timingInput, true);
20 this.timing = shared.makeTiming(timingInput, true);
22 if (this._timing.duration === 'auto')
23 this._timing.duration = this.activeDuration;
26 window.AnimationSequence = function() {
27 constructor.apply(this, arguments);
30 window.AnimationGroup = function() {
31 constructor.apply(this, arguments);
34 window.AnimationSequence.prototype = {
35 get activeDuration() {
37 this.children.forEach(function(child) {
38 total += scope.groupChildDuration(child);
40 return Math.max(total, 0);
44 window.AnimationGroup.prototype = {
45 get activeDuration() {
47 this.children.forEach(function(child) {
48 max = Math.max(max, scope.groupChildDuration(child));
54 scope.newUnderlyingPlayerForGroup = function(group) {
56 var ticker = function(tf) {
57 var player = underlyingPlayer._wrapper;
61 player._removePlayers();
64 if (player.startTime === null)
67 player._updateChildren();
70 underlyingPlayer = scope.timeline.play(new scope.Animation(null, ticker, group._timing));
71 return underlyingPlayer;
74 scope.bindPlayerForGroup = function(player) {
75 player._player._wrapper = player;
76 player._isGroup = true;
77 scope.awaitStartTime(player);
78 player._updateChildren();
82 })(webAnimationsShared, webAnimationsNext, webAnimationsTesting);