fix highlight on scroll
This commit is contained in:
parent
d12c5941ed
commit
608c3f7759
1 changed files with 10 additions and 4 deletions
|
@ -37,10 +37,16 @@ function isVisible(tocIndex) {
|
||||||
: document.querySelectorAll("section.section").item(1);
|
: document.querySelectorAll("section.section").item(1);
|
||||||
|
|
||||||
const c = current.getBoundingClientRect();
|
const c = current.getBoundingClientRect();
|
||||||
|
if (next) {
|
||||||
const n = next.getBoundingClientRect();
|
const n = next.getBoundingClientRect();
|
||||||
const h = (window.innerHeight || document.documentElement.clientHeight);
|
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() {
|
function activateIfVisible() {
|
||||||
|
|
Loading…
Reference in a new issue