From abfacaa856dda66f6088c32b89df066ba44383af Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 8 Feb 2025 11:32:23 +0000 Subject: [PATCH] Fix popover width scaling Fixes #677 --- www/js/lib/popovers.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/www/js/lib/popovers.js b/www/js/lib/popovers.js index c02362ff..85123d9b 100644 --- a/www/js/lib/popovers.js +++ b/www/js/lib/popovers.js @@ -331,13 +331,14 @@ function createNewKiwixPopoverCointainer (win, anchor, event) { const linkHref = anchor.getAttribute('href'); const currentDocument = win.document; div.popoverisloading = true; - const screenWidth = win.innerWidth - 40; - const screenHeight = document.documentElement.clientHeight; let zoomFactor = 'zoom' in currentDocument.documentElement.style && !isSafari() ? params.relativeFontSize / 100 : 1; + // Account for zoom when calculating available screen width + const screenWidth = (win.innerWidth - 40) / zoomFactor; + const screenHeight = document.documentElement.clientHeight; let margin = 40; - let divWidth = 512; - if (screenWidth <= divWidth) { - divWidth = screenWidth; + // Base width scaled by zoom factor + const divWidth = Math.min(512, screenWidth); + if (screenWidth <= 512) { margin = 10; } // Check if we have restricted screen height