| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
| 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 8 --> | 8 --> |
| 9 <link rel="import" href="../polymer/polymer.html"> | 9 <link rel="import" href="../polymer/polymer.html"> |
| 10 <link rel="import" href="../iron-meta/iron-meta.html"> | 10 <link rel="import" href="../iron-meta/iron-meta.html"> |
| 11 <link rel="import" href="neon-animatable-behavior.html"> | 11 <link rel="import" href="neon-animatable-behavior.html"> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * `Polymer.NeonAnimationRunnerBehavior` adds a method to run animations. | 16 * `Polymer.NeonAnimationRunnerBehavior` adds a method to run animations. |
| 17 * @polymerBehavior | 17 * |
| 18 * @polymerBehavior Polymer.NeonAnimationRunnerBehavior |
| 18 */ | 19 */ |
| 19 Polymer.NeonAnimationRunnerBehavior = [Polymer.NeonAnimatableBehavior, { | 20 Polymer.NeonAnimationRunnerBehaviorImpl = { |
| 20 | 21 |
| 21 properties: { | 22 properties: { |
| 22 | 23 |
| 23 _animationMeta: { | 24 _animationMeta: { |
| 24 type: Object, | 25 type: Object, |
| 25 value: function() { | 26 value: function() { |
| 26 return new Polymer.IronMeta({type: 'animation'}); | 27 return new Polymer.IronMeta({type: 'animation'}); |
| 27 } | 28 } |
| 28 }, | 29 }, |
| 29 | 30 |
| 31 /** @type {?Object} */ |
| 30 _player: { | 32 _player: { |
| 31 type: Object | 33 type: Object |
| 32 } | 34 } |
| 33 | 35 |
| 34 }, | 36 }, |
| 35 | 37 |
| 36 _configureAnimationEffects: function(allConfigs) { | 38 _configureAnimationEffects: function(allConfigs) { |
| 37 var allAnimations = []; | 39 var allAnimations = []; |
| 38 if (allConfigs.length > 0) { | 40 if (allConfigs.length > 0) { |
| 39 for (var config, index = 0; config = allConfigs[index]; index++) { | 41 for (var config, index = 0; config = allConfigs[index]; index++) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 } | 52 } |
| 51 } else { | 53 } else { |
| 52 console.warn(this.is + ':', config.name, 'not found!'); | 54 console.warn(this.is + ':', config.name, 'not found!'); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 return allAnimations; | 58 return allAnimations; |
| 57 }, | 59 }, |
| 58 | 60 |
| 59 _runAnimationEffects: function(allEffects) { | 61 _runAnimationEffects: function(allEffects) { |
| 60 return player = document.timeline.play(new GroupEffect(allEffects)); | 62 return document.timeline.play(new GroupEffect(allEffects)); |
| 61 }, | 63 }, |
| 62 | 64 |
| 63 _completeAnimations: function(allAnimations) { | 65 _completeAnimations: function(allAnimations) { |
| 64 for (var animation, index = 0; animation = allAnimations[index]; index++)
{ | 66 for (var animation, index = 0; animation = allAnimations[index]; index++)
{ |
| 65 animation.animation.complete(animation.config); | 67 animation.animation.complete(animation.config); |
| 66 } | 68 } |
| 67 }, | 69 }, |
| 68 | 70 |
| 69 /** | 71 /** |
| 70 * Plays an animation with an optional `type`. | 72 * Plays an animation with an optional `type`. |
| 73 * @param {string=} type |
| 74 * @param {!Object=} cookie |
| 71 */ | 75 */ |
| 72 playAnimation: function(type, cookie) { | 76 playAnimation: function(type, cookie) { |
| 73 var allConfigs = this.getAnimationConfig(type); | 77 var allConfigs = this.getAnimationConfig(type); |
| 74 if (!allConfigs) { | 78 if (!allConfigs) { |
| 75 return; | 79 return; |
| 76 } | 80 } |
| 77 var allAnimations = this._configureAnimationEffects(allConfigs); | 81 var allAnimations = this._configureAnimationEffects(allConfigs); |
| 78 var allEffects = allAnimations.map(function(animation) { | 82 var allEffects = allAnimations.map(function(animation) { |
| 79 return animation.effect; | 83 return animation.effect; |
| 80 }); | 84 }); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 }, | 102 }, |
| 99 | 103 |
| 100 /** | 104 /** |
| 101 * Cancels the currently running animation. | 105 * Cancels the currently running animation. |
| 102 */ | 106 */ |
| 103 cancelAnimation: function() { | 107 cancelAnimation: function() { |
| 104 if (this._player) { | 108 if (this._player) { |
| 105 this._player.cancel(); | 109 this._player.cancel(); |
| 106 } | 110 } |
| 107 } | 111 } |
| 112 }; |
| 108 | 113 |
| 109 }]; | 114 /** @polymerBehavior Polymer.NeonAnimationRunnerBehavior */ |
| 115 Polymer.NeonAnimationRunnerBehavior = [ |
| 116 Polymer.NeonAnimatableBehavior, |
| 117 Polymer.NeonAnimationRunnerBehaviorImpl |
| 118 ]; |
| 110 </script> | 119 </script> |
| OLD | NEW |