MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-animation / core-animation-group-extracted.js
blob3795c375cf3624ade750b44f0e6bcf1b971f4d74
2 (function() {
4 var ANIMATION_GROUPS = {
5 'par': AnimationGroup,
6 'seq': AnimationSequence
7 };
9 Polymer('core-animation-group',{
11 publish: {
12 /**
13 * If target is set, any children without a target will be assigned the group's
14 * target when this property is set.
16 * @property target
17 * @type HTMLElement|Node|Array|Array<HTMLElement|Node>
20 /**
21 * For a `core-animation-group`, a duration of "auto" means the duration should
22 * be the specified duration of its children. If set to anything other than
23 * "auto", any children without a set duration will be assigned the group's duration.
25 * @property duration
26 * @type number
27 * @default "auto"
29 duration: {value: 'auto', reflect: true},
31 /**
32 * The type of the animation group. 'par' creates a parallel group and 'seq' creates
33 * a sequential group.
35 * @property type
36 * @type String
37 * @default 'par'
39 type: {value: 'par', reflect: true}
42 typeChanged: function() {
43 this.apply();
46 targetChanged: function() {
47 // Only propagate target to children animations if it's defined.
48 if (this.target) {
49 this.doOnChildren(function(c) {
50 c.target = this.target;
51 }.bind(this));
55 durationChanged: function() {
56 if (this.duration && this.duration !== 'auto') {
57 this.doOnChildren(function(c) {
58 // Propagate to children that is not a group and has no
59 // duration specified.
60 if (!c.type && (!c.duration || c.duration === 'auto')) {
61 c.duration = this.duration;
63 }.bind(this));
67 doOnChildren: function(inFn) {
68 var children = this.children;
69 if (!children.length) {
70 children = this.shadowRoot ? this.shadowRoot.childNodes : [];
72 Array.prototype.forEach.call(children, function(c) {
73 // TODO <template> in the way
74 c.apply && inFn(c);
75 }, this);
78 makeAnimation: function() {
79 return new ANIMATION_GROUPS[this.type](this.childAnimations, this.timingProps);
82 hasTarget: function() {
83 var ht = this.target !== null;
84 if (!ht) {
85 this.doOnChildren(function(c) {
86 ht = ht || c.hasTarget();
87 }.bind(this));
89 return ht;
92 apply: function() {
93 // Propagate target and duration to child animations first.
94 this.durationChanged();
95 this.targetChanged();
96 this.doOnChildren(function(c) {
97 c.apply();
98 });
99 return this.super();
102 get childAnimationElements() {
103 var list = [];
104 this.doOnChildren(function(c) {
105 if (c.makeAnimation) {
106 list.push(c);
109 return list;
112 get childAnimations() {
113 var list = [];
114 this.doOnChildren(function(c) {
115 if (c.animation) {
116 list.push(c.animation);
119 return list;
123 })();