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

Commit

Permalink
polymer-overlay: auto horizontal centering
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Oct 21, 2013
1 parent 034f5a9 commit 2857627
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions polymer-overlay/polymer-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,20 @@
}
},
positionTarget: function() {
var computedStyle = getComputedStyle(this.target);
if (this.opened && computedStyle.top === 'auto' && computedStyle.bottom === 'auto') {
this.target.style.top = ((window.innerHeight - this.target.getBoundingClientRect().height) / 2) + 'px';
if (this.opened) {
// vertically and horizontally center if not positioned
var computedStyle = getComputedStyle(this.target);
if (computedStyle.top === 'auto' && computedStyle.bottom === 'auto') {
this.target.style.top = ((window.innerHeight - this.target.getBoundingClientRect().height) / 2) + 'px';
}
if (computedStyle.left === 'auto' && computedStyle.right === 'auto') {
this.target.style.left = ((window.innerWidth - this.target.getBoundingClientRect().width) / 2) + 'px';
}
}
},
resetTargetPosition: function() {
this.target.style.top = this.target.style.left = null;
},
renderOpened: function() {
this.target.classList.remove('closing');
this.target.classList.add('revealed');
Expand All @@ -272,6 +281,9 @@
this.animating = null;
this.target.classList.remove('closing');
this.target.classList.toggle('revealed', this.opened);
if (!this.opened) {
this.resetTargetPosition();
}
this.applyFocus();
},
openedAnimationEnd: function(e) {
Expand Down

0 comments on commit 2857627

Please sign in to comment.