2 * `Polymer.NeonAnimationRunnerBehavior` adds a method to run animations.
4 * @polymerBehavior Polymer.NeonAnimationRunnerBehavior
6 Polymer.NeonAnimationRunnerBehaviorImpl = {
13 return new Polymer.IronMeta({type: 'animation'});
17 /** @type {?Object} */
24 _configureAnimationEffects: function(allConfigs) {
25 var allAnimations = [];
26 if (allConfigs.length > 0) {
27 for (var config, index = 0; config = allConfigs[index]; index++) {
28 var animationConstructor = this._animationMeta.byKey(config.name);
29 if (animationConstructor) {
30 var animation = animationConstructor && new animationConstructor();
31 var effect = animation.configure(config);
40 console.warn(this.is + ':', config.name, 'not found!');
47 _runAnimationEffects: function(allEffects) {
48 return document.timeline.play(new GroupEffect(allEffects));
51 _completeAnimations: function(allAnimations) {
52 for (var animation, index = 0; animation = allAnimations[index]; index++) {
53 animation.animation.complete(animation.config);
58 * Plays an animation with an optional `type`.
59 * @param {string=} type
60 * @param {!Object=} cookie
62 playAnimation: function(type, cookie) {
63 var allConfigs = this.getAnimationConfig(type);
67 var allAnimations = this._configureAnimationEffects(allConfigs);
68 var allEffects = allAnimations.map(function(animation) {
69 return animation.effect;
72 if (allEffects.length > 0) {
73 this._player = this._runAnimationEffects(allEffects);
74 this._player.onfinish = function() {
75 this._completeAnimations(allAnimations);
78 this._player.cancel();
82 this.fire('neon-animation-finish', cookie, {bubbles: false});
86 this.fire('neon-animation-finish', cookie, {bubbles: false});
91 * Cancels the currently running animation.
93 cancelAnimation: function() {
95 this._player.cancel();
100 /** @polymerBehavior Polymer.NeonAnimationRunnerBehavior */
101 Polymer.NeonAnimationRunnerBehavior = [
102 Polymer.NeonAnimatableBehavior,
103 Polymer.NeonAnimationRunnerBehaviorImpl