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

Commit

Permalink
polymer-overlay: center target vertically if not positioned
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Oct 17, 2013
1 parent 2609d8a commit 1693d64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions polymer-overlay/polymer-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@
focusOverlay();
}
},
positionTarget: function() {
var computedStyle = getComputedStyle(this.target);
if (this.opened && computedStyle.top === 'auto' && computedStyle.bottom === 'auto') {
this.target.style.width = (window.innerWidth - 20) + 'px';
this.target.style.top = ((window.innerHeight - this.target.getBoundingClientRect().height) / 2) + 'px';
}
},
renderOpened: function() {
this.target.classList.remove('closing');
this.target.classList.add('revealed');
Expand All @@ -256,6 +263,7 @@
this.asyncMethod('continueRenderOpened');
},
continueRenderOpened: function() {
this.positionTarget();
this.target.classList.toggle('opened', this.opened);
this.target.classList.toggle('closing', !this.opened);
this.animating = this.asyncMethod('completeOpening', null, this.timeout);
Expand Down

0 comments on commit 1693d64

Please sign in to comment.