From 8a28c28068f4328378df1d75bd5a7cf7c0ac3906 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Mon, 28 Oct 2013 15:23:36 -0700 Subject: [PATCH] polymer-overlay: only override transition target if null --- polymer-animation/polymer-animation-group.html | 9 +++++++++ polymer-animation/polymer-animation.html | 3 +++ polymer-overlay/polymer-overlay.html | 7 ++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/polymer-animation/polymer-animation-group.html b/polymer-animation/polymer-animation-group.html index 8d725f3..17447c2 100644 --- a/polymer-animation/polymer-animation-group.html +++ b/polymer-animation/polymer-animation-group.html @@ -73,6 +73,15 @@ makeAnimation: function() { return new ANIMATION_GROUPS[this.type](this.childAnimations, this.timingProps); }, + hasTarget: function() { + var ht = this.target !== null; + if (!ht) { + this.doOnChildren(function(c) { + ht = ht || c.hasTarget(); + }.bind(this)); + } + return ht; + }, apply: function() { // Propagate target and duration to child animations first. this.durationChanged(); diff --git a/polymer-animation/polymer-animation.html b/polymer-animation/polymer-animation.html index d477088..a43425b 100644 --- a/polymer-animation/polymer-animation.html +++ b/polymer-animation/polymer-animation.html @@ -188,6 +188,9 @@ this.player.source = null; } }, + hasTarget: function() { + return this.target !== null; + }, apply: function() { this.animation = null; this.animation = this.makeAnimation(); diff --git a/polymer-overlay/polymer-overlay.html b/polymer-overlay/polymer-overlay.html index 8994492..9437e92 100644 --- a/polymer-overlay/polymer-overlay.html +++ b/polymer-overlay/polymer-overlay.html @@ -272,7 +272,7 @@ this.target.style.top = this.target.style.left = null; }, get transition() { - return (this.transitions && !Array.isArray(this.transitions) + return (!Array.isArray(this.transitions) && this.transitions || this.opened && this.transitions && this.transitions[0] || !this.opened && this.transitions && this.transitions[1]); }, @@ -280,11 +280,12 @@ var animation = typeof this.transition === 'string' ? document.createElement(this.transition) : this.transition; // FIXME: Apply a default duration. - console.log('animation', animation.duration, animation.type); if ((!animation.duration || animation.duration === 'auto') && !animation.type) { animation.duration = 0.3; } - animation.target = this.target; + if (!animation.hasTarget()) { + animation.target = this.target; + } // Make the overlay visible while the animation is running. var transition = new ParGroup([ animation.makeAnimation(),