From 446c675a3e2e71742ffa38d93c0728dc1337ae09 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 13 Jun 2025 03:59:07 +0200 Subject: Fix sidenotes width problem --- src/js/sidenotes.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/js') diff --git a/src/js/sidenotes.js b/src/js/sidenotes.js index 591f856..9519c88 100644 --- a/src/js/sidenotes.js +++ b/src/js/sidenotes.js @@ -18,7 +18,11 @@ function getPos(element) { let articles; const resize = () => { for (const [article, sidenote] of articles) { - if (sidenote.offsetWidth < 200 || window.screen.width < 1400) { + const viewportWidth = + window.innerWidth || + document.documentElement.clientWidth || + document.body.clientWidth; + if (sidenote.offsetWidth < 200 || viewportWidth < 1400) { sidenote.innerHTML = ""; return; } @@ -51,7 +55,7 @@ const resize = () => { sidenote.replaceChildren(...newSidenotes); - if (sidenote.offsetWidth < 100 || window.screen.width < 1400) { + if (sidenote.offsetWidth < 100 || viewportWidth < 1400) { sidenote.innerHTML = ""; return; } -- cgit v1.3-2-g11bf