From a5bc133d5e1b24828674a6191a4bb334edd5d625 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 10 Jun 2024 16:39:47 +0200 Subject: [PATCH] Center popup placement on narrow screens Previous calculation resulted in out of screen placement on insanely narrow screens. --- service2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service2.js b/service2.js index 0914204..e51c13a 100644 --- a/service2.js +++ b/service2.js @@ -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` } }