Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 8a28c28

Browse files
author
Yvonne Yip
committed
polymer-overlay: only override transition target if null
1 parent 0a18a5c commit 8a28c28

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

polymer-animation/polymer-animation-group.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
makeAnimation: function() {
7474
return new ANIMATION_GROUPS[this.type](this.childAnimations, this.timingProps);
7575
},
76+
hasTarget: function() {
77+
var ht = this.target !== null;
78+
if (!ht) {
79+
this.doOnChildren(function(c) {
80+
ht = ht || c.hasTarget();
81+
}.bind(this));
82+
}
83+
return ht;
84+
},
7685
apply: function() {
7786
// Propagate target and duration to child animations first.
7887
this.durationChanged();

polymer-animation/polymer-animation.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
this.player.source = null;
189189
}
190190
},
191+
hasTarget: function() {
192+
return this.target !== null;
193+
},
191194
apply: function() {
192195
this.animation = null;
193196
this.animation = this.makeAnimation();

polymer-overlay/polymer-overlay.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,20 @@
272272
this.target.style.top = this.target.style.left = null;
273273
},
274274
get transition() {
275-
return (this.transitions && !Array.isArray(this.transitions)
275+
return (!Array.isArray(this.transitions) && this.transitions
276276
|| this.opened && this.transitions && this.transitions[0]
277277
|| !this.opened && this.transitions && this.transitions[1]);
278278
},
279279
applyTransition: function() {
280280
var animation = typeof this.transition === 'string' ?
281281
document.createElement(this.transition) : this.transition;
282282
// FIXME: Apply a default duration.
283-
console.log('animation', animation.duration, animation.type);
284283
if ((!animation.duration || animation.duration === 'auto') && !animation.type) {
285284
animation.duration = 0.3;
286285
}
287-
animation.target = this.target;
286+
if (!animation.hasTarget()) {
287+
animation.target = this.target;
288+
}
288289
// Make the overlay visible while the animation is running.
289290
var transition = new ParGroup([
290291
animation.makeAnimation(),

0 commit comments

Comments
 (0)