on master help sign in
Fuzzier "active" navigation
commitcd2b2826201b09de52b1d4e8fbc732b9e3d256bb authorMatilde Park <matilde@tlon.io> dateTue 10 Sep 2019, 15:56 (7 years ago) parent209a84c
1 file changed+4−2
static/scripts.js+4−2
static/scripts.js+4−2
@@ -354,10 +354,12 @@ window.addEventListener("scroll", event => {
354354
355355 all.forEach(link => {
356356 let section = document.querySelector(link.hash);
357+ let sectionChildren = document.querySelector(link.hash).nextElementSibling;
357358
358359 if (
359− section.offsetTop <= fromTop &&
360− section.offsetTop + section.offsetHeight > fromTop
360+ ((section.offsetTop <= fromTop) ||
361+ (sectionChildren.offsetTop <= fromTop)) &&
362+ (section.offsetTop + section.offsetHeight + sectionChildren.offsetHeight > fromTop)
361363 ) {
362364 link.classList.add("current");
363365 } else {