4 * `Polymer.NeonAnimationRunnerBehavior` adds a method to run animations.
6 * @polymerBehavior Polymer.NeonAnimationRunnerBehavior
8 Polymer
.NeonAnimationRunnerBehaviorImpl
= {
15 return new Polymer
.IronMeta({type
: 'animation'});
19 /** @type {?Object} */
26 _configureAnimationEffects: function(allConfigs
) {
27 var allAnimations
= [];
28 if (allConfigs
.length
> 0) {
29 for (var config
, index
= 0; config
= allConfigs
[index
]; index
++) {
30 var animationConstructor
= this._animationMeta
.byKey(config
.name
);
31 if (animationConstructor
) {
32 var animation
= animationConstructor
&& new animationConstructor();
33 var effect
= animation
.configure(config
);
42 console
.warn(this.is
+ ':', config
.name
, 'not found!');
49 _runAnimationEffects: function(allEffects
) {
50 return document
.timeline
.play(new GroupEffect(allEffects
));
53 _completeAnimations: function(allAnimations
) {
54 for (var animation
, index
= 0; animation
= allAnimations
[index
]; index
++) {
55 animation
.animation
.complete(animation
.config
);
60 * Plays an animation with an optional `type`.
61 * @param {string=} type
62 * @param {!Object=} cookie
64 playAnimation: function(type
, cookie
) {
65 var allConfigs
= this.getAnimationConfig(type
);
69 var allAnimations
= this._configureAnimationEffects(allConfigs
);
70 var allEffects
= allAnimations
.map(function(animation
) {
71 return animation
.effect
;
74 if (allEffects
.length
> 0) {
75 this._player
= this._runAnimationEffects(allEffects
);
76 this._player
.onfinish = function() {
77 this._completeAnimations(allAnimations
);
80 this._player
.cancel();
84 this.fire('neon-animation-finish', cookie
, {bubbles
: false});
88 this.fire('neon-animation-finish', cookie
, {bubbles
: false});
93 * Cancels the currently running animation.
95 cancelAnimation: function() {
97 this._player
.cancel();
102 /** @polymerBehavior Polymer.NeonAnimationRunnerBehavior */
103 Polymer
.NeonAnimationRunnerBehavior
= [
104 Polymer
.NeonAnimatableBehavior
,
105 Polymer
.NeonAnimationRunnerBehaviorImpl