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

Commit

Permalink
fix positioning on FF/IE.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 1, 2014
1 parent 4d471a0 commit e963728
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions core-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@

updateTargetDimensions: function() {
if (this.opened) {
if (!this._shouldPosition) {
this.target.style.position = 'static';
var computed = getComputedStyle(this.target);
var t = (computed.top === 'auto' && computed.bottom === 'auto');
var l = (computed.left === 'auto' && computed.right === 'auto');
this.target.style.position = '';
this._shouldPosition = {top: t, left: l};
}

this.sizeTarget();
this.positionTarget();
}
Expand All @@ -285,22 +294,11 @@
positionTarget: function() {
// vertically and horizontally center if not positioned
var rect = this.target.getBoundingClientRect();
var computed;
if (this._shouldPositionTop === undefined) {
computed = computed || getComputedStyle(this.target);
this._shouldPositionTop = (computed.top === 'auto' &&
computed.bottom === 'auto');
}
if (this._shouldPositionLeft === undefined) {
computed = computed || getComputedStyle(this.target);
this._shouldPositionLeft = (computed.left === 'auto' &&
computed.right === 'auto');
}
if (this._shouldPositionTop) {
if (this._shouldPosition.top) {
var t = Math.max((window.innerHeight - rect.height) / 2, 0);
this.target.style.top = t + 'px';
}
if (this._shouldPositionLeft) {
if (this._shouldPosition.left) {
var l = Math.max((window.innerWidth - rect.width) / 2, 0);
this.target.style.left = l + 'px';
}
Expand All @@ -309,6 +307,7 @@
resetTargetDimensions: function() {
this.target.style.top = this.target.style.left = null;
this.target.style.width = this.target.style.height = null;
this._shouldPosition = null;
},

tapHandler: function(e) {
Expand Down

0 comments on commit e963728

Please sign in to comment.