OLD | NEW |
1 <!-- | 1 <!-- |
2 @license | 2 @license |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 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 | 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 | 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 | 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 | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 <link rel="import" href="../polymer/polymer.html"> | 10 <link rel="import" href="../polymer/polymer.html"> |
(...skipping 27 matching lines...) Expand all Loading... |
38 if (animation.isNeonAnimation) { | 38 if (animation.isNeonAnimation) { |
39 var effect = animation.configure(config); | 39 var effect = animation.configure(config); |
40 if (effect) { | 40 if (effect) { |
41 allAnimations.push({ | 41 allAnimations.push({ |
42 animation: animation, | 42 animation: animation, |
43 config: config, | 43 config: config, |
44 effect: effect | 44 effect: effect |
45 }); | 45 }); |
46 } | 46 } |
47 } else { | 47 } else { |
48 Polymer.Base._warn(this.is + ':', config.name, 'not found!'); | 48 console.warn(this.is + ':', config.name, 'not found!'); |
49 } | 49 } |
50 } | 50 } |
51 } | 51 } |
52 return allAnimations; | 52 return allAnimations; |
53 }, | 53 }, |
54 | 54 |
55 _runAnimationEffects: function(allEffects) { | 55 _runAnimationEffects: function(allEffects) { |
56 return document.timeline.play(new GroupEffect(allEffects)); | 56 return document.timeline.play(new GroupEffect(allEffects)); |
57 }, | 57 }, |
58 | 58 |
59 _completeAnimations: function(allAnimations) { | 59 _completeAnimations: function(allAnimations) { |
60 for (var animation, index = 0; animation = allAnimations[index]; index++)
{ | 60 for (var animation, index = 0; animation = allAnimations[index]; index++)
{ |
61 animation.animation.complete(animation.config); | 61 animation.animation.complete(animation.config); |
62 } | 62 } |
63 }, | 63 }, |
64 | 64 |
65 /** | 65 /** |
66 * Plays an animation with an optional `type`. | 66 * Plays an animation with an optional `type`. |
67 * @param {string=} type | 67 * @param {string=} type |
68 * @param {!Object=} cookie | 68 * @param {!Object=} cookie |
69 */ | 69 */ |
70 playAnimation: function(type, cookie) { | 70 playAnimation: function(type, cookie) { |
71 var allConfigs = this.getAnimationConfig(type); | 71 var allConfigs = this.getAnimationConfig(type); |
72 if (!allConfigs) { | 72 if (!allConfigs) { |
73 return; | 73 return; |
74 } | 74 } |
75 var allAnimations = this._configureAnimationEffects(allConfigs); | 75 try { |
76 var allEffects = allAnimations.map(function(animation) { | 76 var allAnimations = this._configureAnimationEffects(allConfigs); |
77 return animation.effect; | 77 var allEffects = allAnimations.map(function(animation) { |
78 }); | 78 return animation.effect; |
| 79 }); |
79 | 80 |
80 if (allEffects.length > 0) { | 81 if (allEffects.length > 0) { |
81 this._player = this._runAnimationEffects(allEffects); | 82 this._player = this._runAnimationEffects(allEffects); |
82 this._player.onfinish = function() { | 83 this._player.onfinish = function() { |
83 this._completeAnimations(allAnimations); | 84 this._completeAnimations(allAnimations); |
84 | 85 |
85 if (this._player) { | 86 if (this._player) { |
86 this._player.cancel(); | 87 this._player.cancel(); |
87 this._player = null; | 88 this._player = null; |
88 } | 89 } |
89 | 90 |
90 this.fire('neon-animation-finish', cookie, {bubbles: false}); | 91 this.fire('neon-animation-finish', cookie, {bubbles: false}); |
91 }.bind(this); | 92 }.bind(this); |
92 | 93 return; |
93 } else { | 94 } |
94 this.fire('neon-animation-finish', cookie, {bubbles: false}); | 95 } catch (e) { |
| 96 console.warn('Couldnt play', '(', type, allConfigs, ').', e); |
95 } | 97 } |
| 98 this.fire('neon-animation-finish', cookie, {bubbles: false}); |
96 }, | 99 }, |
97 | 100 |
98 /** | 101 /** |
99 * Cancels the currently running animation. | 102 * Cancels the currently running animation. |
100 */ | 103 */ |
101 cancelAnimation: function() { | 104 cancelAnimation: function() { |
102 if (this._player) { | 105 if (this._player) { |
103 this._player.cancel(); | 106 this._player.cancel(); |
104 } | 107 } |
105 } | 108 } |
106 }; | 109 }; |
107 | 110 |
108 /** @polymerBehavior Polymer.NeonAnimationRunnerBehavior */ | 111 /** @polymerBehavior Polymer.NeonAnimationRunnerBehavior */ |
109 Polymer.NeonAnimationRunnerBehavior = [ | 112 Polymer.NeonAnimationRunnerBehavior = [ |
110 Polymer.NeonAnimatableBehavior, | 113 Polymer.NeonAnimatableBehavior, |
111 Polymer.NeonAnimationRunnerBehaviorImpl | 114 Polymer.NeonAnimationRunnerBehaviorImpl |
112 ]; | 115 ]; |
113 </script> | 116 </script> |
OLD | NEW |