OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 Google Inc. All rights reserved. |
| 2 // |
| 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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 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. |
| 14 |
| 15 (function(shared, scope, testing) { |
| 16 |
| 17 function constructor(children, timingInput) { |
| 18 this.children = children || []; |
| 19 this._timing = shared.normalizeTimingInput(timingInput, true); |
| 20 this.timing = shared.makeTiming(timingInput, true); |
| 21 |
| 22 if (this._timing.duration === 'auto') |
| 23 this._timing.duration = this.activeDuration; |
| 24 } |
| 25 |
| 26 window.AnimationSequence = function() { |
| 27 constructor.apply(this, arguments); |
| 28 }; |
| 29 |
| 30 window.AnimationGroup = function() { |
| 31 constructor.apply(this, arguments); |
| 32 }; |
| 33 |
| 34 window.AnimationSequence.prototype = { |
| 35 get activeDuration() { |
| 36 var total = 0; |
| 37 this.children.forEach(function(child) { |
| 38 total += scope.groupChildDuration(child); |
| 39 }); |
| 40 return Math.max(total, 0); |
| 41 } |
| 42 }; |
| 43 |
| 44 window.AnimationGroup.prototype = { |
| 45 get activeDuration() { |
| 46 var max = 0; |
| 47 this.children.forEach(function(child) { |
| 48 max = Math.max(max, scope.groupChildDuration(child)); |
| 49 }); |
| 50 return max; |
| 51 } |
| 52 }; |
| 53 |
| 54 scope.newUnderlyingPlayerForGroup = function(group) { |
| 55 var underlyingPlayer; |
| 56 var ticker = function(tf) { |
| 57 var player = underlyingPlayer._wrapper; |
| 58 if (!player.source) |
| 59 return; |
| 60 if (tf == null) { |
| 61 player._removePlayers(); |
| 62 return; |
| 63 } |
| 64 if (player.startTime === null) |
| 65 return; |
| 66 |
| 67 player._updateChildren(); |
| 68 }; |
| 69 |
| 70 underlyingPlayer = scope.timeline.play(new scope.Animation(null, ticker, gro
up._timing)); |
| 71 return underlyingPlayer; |
| 72 }; |
| 73 |
| 74 scope.bindPlayerForGroup = function(player) { |
| 75 player._player._wrapper = player; |
| 76 player._isGroup = true; |
| 77 scope.awaitStartTime(player); |
| 78 }; |
| 79 |
| 80 |
| 81 })(webAnimationsShared, webAnimationsMaxifill, webAnimationsTesting); |
OLD | NEW |