17
0
Fork 0

fix highlight on scroll

This commit is contained in:
Alex 2022-01-31 17:16:02 +01:00
parent d12c5941ed
commit 608c3f7759
No known key found for this signature in database
GPG Key ID: EDABF9711E244EB1
1 changed files with 10 additions and 4 deletions

View File

@ -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;
});
</script>
</script>