fix annoying popup window behavior near window borders

This commit is contained in:
Alex Yatskov 2017-01-10 19:26:31 -08:00
parent 01d73dd2ad
commit 20c5ca1bf5

View File

@ -46,16 +46,14 @@ class Popup {
let x = elementRect.left; let x = elementRect.left;
let width = containerWidth; let width = containerWidth;
if (x + width >= window.innerWidth) { if (x + width >= window.innerWidth) {
const widthMax = window.innerWidth - x; width = Math.min(width, x);
width = Math.min(width, widthMax);
x = window.innerWidth - width; x = window.innerWidth - width;
} }
let y = elementRect.bottom + this.offset; let y = elementRect.bottom + this.offset;
let height = containerHeight; let height = containerHeight;
if (y + height >= window.innerHeight) { if (y + height >= window.innerHeight) {
const heightMax = window.innerHeight - y - this.offset; height = Math.min(height, y);
height = Math.min(height, heightMax);
y = elementRect.top - height - this.offset; y = elementRect.top - height - this.offset;
} }