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