From 608c3f7759f2edf6b8defcf2abe0a9031184c136 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 31 Jan 2022 17:16:02 +0100 Subject: fix highlight on scroll --- templates/partials/doc/toc_script.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'templates/partials/doc') diff --git a/templates/partials/doc/toc_script.html b/templates/partials/doc/toc_script.html index 1453a69..7d10ee6 100644 --- a/templates/partials/doc/toc_script.html +++ b/templates/partials/doc/toc_script.html @@ -37,10 +37,16 @@ function isVisible(tocIndex) { : document.querySelectorAll("section.section").item(1); const c = current.getBoundingClientRect(); - const n = next.getBoundingClientRect(); - const h = (window.innerHeight || document.documentElement.clientHeight); + if (next) { + const n = next.getBoundingClientRect(); + const h = (window.innerHeight || document.documentElement.clientHeight); - return (c.top <= h) && (n.top - menuBarHeight >= 0); + return (c.top <= h) && (n.top - menuBarHeight >= 0); + } else { + const h = (window.innerHeight || document.documentElement.clientHeight); + + return (c.top <= h); + } } function activateIfVisible() { @@ -73,4 +79,4 @@ document.addEventListener("DOMContentLoaded", function() { activeDocPage.parentElement.parentElement.previousElementSibling.previousElementSibling.checked = false; }); - \ No newline at end of file + -- cgit v1.2.3