OLD | NEW |
1 | 1 |
2 | 2 |
3 Polymer({ | 3 Polymer({ |
4 | 4 |
5 is: 'cascaded-animation', | 5 is: 'cascaded-animation', |
6 | 6 |
7 behaviors: [ | 7 behaviors: [ |
8 Polymer.NeonAnimationBehavior | 8 Polymer.NeonAnimationBehavior |
9 ], | 9 ], |
10 | 10 |
11 properties: { | 11 properties: { |
12 | 12 |
| 13 /** @type {!Polymer.IronMeta} */ |
13 _animationMeta: { | 14 _animationMeta: { |
14 type: Object, | 15 type: Object, |
15 value: function() { | 16 value: function() { |
16 return new Polymer.IronMeta({type: 'animation'}); | 17 return new Polymer.IronMeta({type: 'animation'}); |
17 } | 18 } |
18 } | 19 } |
19 | 20 |
20 }, | 21 }, |
21 | 22 |
| 23 /** |
| 24 * @param {{ |
| 25 * animation: string, |
| 26 * nodes: !Array<!Element>, |
| 27 * nodeDelay: (number|undefined), |
| 28 * timing: (Object|undefined) |
| 29 * }} config |
| 30 */ |
22 configure: function(config) { | 31 configure: function(config) { |
23 var animationConstructor = this._animationMeta.byKey(config.animation); | 32 var animationConstructor = /** @type {Function} */ ( |
| 33 this._animationMeta.byKey(config.animation)); |
24 if (!animationConstructor) { | 34 if (!animationConstructor) { |
25 console.warn(this.is + ':', 'constructor for', config.animation, 'not fo
und!'); | 35 console.warn(this.is + ':', 'constructor for', config.animation, 'not fo
und!'); |
26 return; | 36 return; |
27 } | 37 } |
28 | 38 |
| 39 this._animations = []; |
29 var nodes = config.nodes; | 40 var nodes = config.nodes; |
30 var effects = []; | 41 var effects = []; |
31 var nodeDelay = config.nodeDelay || 50; | 42 var nodeDelay = config.nodeDelay || 50; |
32 | 43 |
33 config.timing = config.timing || {}; | 44 config.timing = config.timing || {}; |
34 config.timing.delay = config.timing.delay || 0; | 45 config.timing.delay = config.timing.delay || 0; |
35 | 46 |
36 var oldDelay = config.timing.delay; | 47 var oldDelay = config.timing.delay; |
37 for (var node, index = 0; node = nodes[index]; index++) { | 48 for (var node, index = 0; node = nodes[index]; index++) { |
38 config.timing.delay += nodeDelay; | 49 config.timing.delay += nodeDelay; |
39 config.node = node; | 50 config.node = node; |
40 | 51 |
41 var animation = new animationConstructor(); | 52 var animation = new animationConstructor(); |
42 var effect = animation.configure(config); | 53 var effect = animation.configure(config); |
43 | 54 |
| 55 this._animations.push(animation); |
44 effects.push(effect); | 56 effects.push(effect); |
45 } | 57 } |
46 config.timing.delay = oldDelay; | 58 config.timing.delay = oldDelay; |
47 | 59 |
48 this._effect = new GroupEffect(effects); | 60 this._effect = new GroupEffect(effects); |
49 return this._effect; | 61 return this._effect; |
| 62 }, |
| 63 |
| 64 complete: function() { |
| 65 for (var animation, index = 0; animation = this._animations[index]; index+
+) { |
| 66 animation.complete(animation.config); |
| 67 } |
50 } | 68 } |
51 | 69 |
52 }); | 70 }); |
53 | 71 |
OLD | NEW |