temporary fix for the toc links (also better logic for scrollArray)

This commit is contained in:
Spax
2025-11-02 16:43:37 -07:00
parent 596a3e672b
commit ee627f32d0
2 changed files with 7 additions and 4 deletions

View File

@@ -128,7 +128,8 @@ a.ltx_LaTeXML_logo:visited {
} }
.ltx_TOC a { .ltx_TOC a {
display: block; width: 100%; display: block;
width: 100%;
} }
.ltx_TOC { .ltx_TOC {

View File

@@ -8,8 +8,8 @@ function initTocOnClick() {
coll.classList.toggle("active"); coll.classList.toggle("active");
const content = coll.nextElementSibling; const content = coll.nextElementSibling;
if (content) { if (content) {
event.preventDefault(); // don't jump
if (content.style.maxHeight) { if (content.style.maxHeight) {
event.preventDefault(); // don't jump if closing
content.style.maxHeight = null; content.style.maxHeight = null;
} else { } else {
content.style.maxHeight = content.scrollHeight + "px"; content.style.maxHeight = content.scrollHeight + "px";
@@ -122,8 +122,10 @@ function saveScroll() {
const pos = window.scrollY; const pos = window.scrollY;
const scrollArray = JSON.parse(sessionStorage.getItem("scrollPos") ?? "[]"); const scrollArray = JSON.parse(sessionStorage.getItem("scrollPos") ?? "[]");
scrollArray.unshift(pos); if (scrollArray[0] !== Math.round(pos)) {
sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray)); scrollArray.unshift(Math.round(pos));
sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray));
}
}); });
} }
} }