Center popup placement on narrow screens

Previous calculation resulted in out of screen placement on insanely
narrow screens.
This commit is contained in:
Simon Rozman 2024-06-10 16:39:47 +02:00
parent 56a27c8432
commit a5bc133d5e

View File

@ -1475,7 +1475,7 @@ class BesPopup extends HTMLElement {
} else if (this.offsetWidth <= x) {
this.style.left = `${x - this.offsetWidth}px`
} else {
this.style.left = `${x - this.offsetWidth / 2}px`
this.style.left = `${(window.innerWidth - this.offsetWidth) / 2}px`
}
if (y + 20 + this.offsetHeight <= window.innerHeight) {
@ -1483,7 +1483,7 @@ class BesPopup extends HTMLElement {
} else if (this.offsetHeight <= y) {
this.style.top = `${y - this.offsetHeight}px`
} else {
this.style.top = `${y - this.offsetHeight / 2}px`
this.style.top = `${(window.innerHeight - this.offsetHeight) / 2}px`
}
}