From 5d8c687f7095e7facff297f83f812d559467d004 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Tue, 29 Oct 2013 12:57:11 -0700 Subject: [PATCH] polymer-animation: can have multiple targets --- polymer-animation/polymer-animation.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/polymer-animation/polymer-animation.html b/polymer-animation/polymer-animation.html index a43425b..6e6076f 100644 --- a/polymer-animation/polymer-animation.html +++ b/polymer-animation/polymer-animation.html @@ -58,9 +58,9 @@ */ Polymer('polymer-animation', { /** - * The node being animated. + * One or more nodes to animate. * @property target - * @type HTMLElement|Node + * @type HTMLElement|Node|Array */ target: null, /** @@ -199,9 +199,26 @@ } return this.animation; }, + makeSingleAnimation: function(target) { + return new Animation(target, this.animationEffect, this.timingProps); + }, makeAnimation: function() { // this.target && console.log('makeAnimation target', this.target, 'animation', this.animationEffect, 'timing', this.timingProps); - return this.target ? new Animation(this.target, this.animationEffect, this.timingProps) : null; + if (!this.target) { + return null; + } + var animation; + if (Array.isArray(this.target)) { + var array = []; + this.target.forEach(function(t) { + array.push(this.makeSingleAnimation(t)); + }); + animation = new ParGroup(array); + } else { + animation = this.makeSingleAnimation(this.target); + } + return animation; + // return this.target ? new Animation(this.target, this.animationEffect, this.timingProps) : null; }, animationChanged: function() { // TODO: attributes are not case sensitive.