OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <link rel="import" href="../../polymer/polymer.html"> |
| 12 <link rel="import" href="../neon-animation-behavior.html"> |
| 13 <link rel="import" href="../web-animations.html"> |
| 14 |
| 15 <!-- |
| 16 `<cascaded-animation>` applies an animation on an array of elements with a delay
between each. |
| 17 the delay defaults to 50ms. |
| 18 |
| 19 Configuration: |
| 20 ``` |
| 21 { |
| 22 name: 'cascaded-animation', |
| 23 animation: <animation-name>, |
| 24 nodes: <array-of-nodes>, |
| 25 nodedelay: <node-delay-in-ms>, |
| 26 timing: <animation-timing> |
| 27 } |
| 28 ``` |
| 29 --> |
| 30 |
| 31 <script> |
| 32 |
| 33 Polymer({ |
| 34 |
| 35 is: 'cascaded-animation', |
| 36 |
| 37 behaviors: [ |
| 38 Polymer.NeonAnimationBehavior |
| 39 ], |
| 40 |
| 41 properties: { |
| 42 |
| 43 _animationMeta: { |
| 44 type: Object, |
| 45 value: function() { |
| 46 return new Polymer.IronMeta({type: 'animation'}); |
| 47 } |
| 48 } |
| 49 |
| 50 }, |
| 51 |
| 52 configure: function(config) { |
| 53 var animationConstructor = this._animationMeta.byKey(config.animation); |
| 54 if (!animationConstructor) { |
| 55 console.warn(this.is + ':', 'constructor for', config.animation, 'not fo
und!'); |
| 56 return; |
| 57 } |
| 58 |
| 59 var nodes = config.nodes; |
| 60 var effects = []; |
| 61 var nodeDelay = config.nodeDelay || 50; |
| 62 |
| 63 config.timing = config.timing || {}; |
| 64 config.timing.delay = config.timing.delay || 0; |
| 65 |
| 66 var oldDelay = config.timing.delay; |
| 67 for (var node, index = 0; node = nodes[index]; index++) { |
| 68 config.timing.delay += nodeDelay; |
| 69 config.node = node; |
| 70 |
| 71 var animation = new animationConstructor(); |
| 72 var effect = animation.configure(config); |
| 73 |
| 74 effects.push(effect); |
| 75 } |
| 76 config.timing.delay = oldDelay; |
| 77 |
| 78 this._effect = new GroupEffect(effects); |
| 79 return this._effect; |
| 80 } |
| 81 |
| 82 }); |
| 83 |
| 84 </script> |
OLD | NEW |