porting popup window dimension calculation fix
This commit is contained in:
parent
916751420e
commit
dcd17bc654
@ -38,21 +38,21 @@ class Popup {
|
|||||||
showNextTo(elementRect, content) {
|
showNextTo(elementRect, content) {
|
||||||
this.inject();
|
this.inject();
|
||||||
|
|
||||||
const containerRect = this.container.getBoundingClientRect();
|
const containerStyle = window.getComputedStyle(this.container);
|
||||||
|
const containerHeight = parseInt(containerStyle.height);
|
||||||
|
const containerWidth = parseInt(containerStyle.width);
|
||||||
|
|
||||||
let x = elementRect.left;
|
let x = elementRect.left;
|
||||||
let width = containerRect.width;
|
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 = containerRect.height;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user