aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-31 17:16:02 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-31 17:16:02 +0100
commit608c3f7759f2edf6b8defcf2abe0a9031184c136 (patch)
tree721cf6f62e9eb502060afc076e22a32871add67b
parentd12c5941ed405772f979f5857aaf42b9b12ae420 (diff)
downloadgaragehq.deuxfleurs.fr-608c3f7759f2edf6b8defcf2abe0a9031184c136.tar.gz
garagehq.deuxfleurs.fr-608c3f7759f2edf6b8defcf2abe0a9031184c136.zip
fix highlight on scroll
-rw-r--r--templates/partials/doc/toc_script.html14
1 files changed, 10 insertions, 4 deletions
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;
});
-</script> \ No newline at end of file
+</script>