From 1693d64ece1463e1e423c9b474b8f80d5ca41379 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Thu, 17 Oct 2013 16:47:21 -0700 Subject: [PATCH] polymer-overlay: center target vertically if not positioned --- polymer-overlay/polymer-overlay.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/polymer-overlay/polymer-overlay.html b/polymer-overlay/polymer-overlay.html index dc20994..9259da3 100644 --- a/polymer-overlay/polymer-overlay.html +++ b/polymer-overlay/polymer-overlay.html @@ -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'); @@ -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);