From ee627f32d00ab4ec27fa7f2a29197becb9de6cf0 Mon Sep 17 00:00:00 2001 From: Spax Date: Sun, 2 Nov 2025 16:43:37 -0700 Subject: [PATCH] temporary fix for the toc links (also better logic for scrollArray) --- export/pghrtcss.css | 3 ++- export/pghrtjs.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/export/pghrtcss.css b/export/pghrtcss.css index c48d6ef..b47a137 100644 --- a/export/pghrtcss.css +++ b/export/pghrtcss.css @@ -128,7 +128,8 @@ a.ltx_LaTeXML_logo:visited { } .ltx_TOC a { - display: block; width: 100%; + display: block; + width: 100%; } .ltx_TOC { diff --git a/export/pghrtjs.js b/export/pghrtjs.js index 98fcd70..2a6b323 100644 --- a/export/pghrtjs.js +++ b/export/pghrtjs.js @@ -8,8 +8,8 @@ function initTocOnClick() { coll.classList.toggle("active"); const content = coll.nextElementSibling; if (content) { - event.preventDefault(); // don't jump if (content.style.maxHeight) { + event.preventDefault(); // don't jump if closing content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; @@ -122,8 +122,10 @@ function saveScroll() { const pos = window.scrollY; const scrollArray = JSON.parse(sessionStorage.getItem("scrollPos") ?? "[]"); - scrollArray.unshift(pos); - sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray)); + if (scrollArray[0] !== Math.round(pos)) { + scrollArray.unshift(Math.round(pos)); + sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray)); + } }); } }