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

Commit

Permalink
polymer-overlay: only override transition target if null
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Oct 28, 2013
1 parent 0a18a5c commit 8a28c28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions polymer-animation/polymer-animation-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions polymer-animation/polymer-animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
this.player.source = null;
}
},
hasTarget: function() {
return this.target !== null;
},
apply: function() {
this.animation = null;
this.animation = this.makeAnimation();
Expand Down
7 changes: 4 additions & 3 deletions polymer-overlay/polymer-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,20 @@
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]);
},
applyTransition: function() {
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(),
Expand Down

0 comments on commit 8a28c28

Please sign in to comment.