mirror of
https://github.com/tchartron/blow
synced 2025-02-17 13:48:27 +00:00
1 line
No EOL
583 B
JavaScript
1 line
No EOL
583 B
JavaScript
function setActiveToc(e){return[...e].find(e=>e.getBoundingClientRect().y<0)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");const e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let t=!1,n=[];[...e].forEach(e=>{n.push(e.href.substring(e.href.indexOf("#")))});var o=document.querySelectorAll(n.join(","));console.log(o);let c=[...o].reverse();window.addEventListener("scroll",()=>{!1===t?(e[0].classList.add("bg-blue-800"),t=e[0]):console.log(setActiveToc(c))})}); |