mirror of
https://github.com/tchartron/blow
synced 2024-12-01 00:29:16 +00:00
1 line
No EOL
716 B
JavaScript
1 line
No EOL
716 B
JavaScript
function activeTocItem(){var e=window.scrollY;console.log(e)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc"),document.getElementById("page-content");window.addEventListener("scroll",activeTocItem);const t=new window.IntersectionObserver(e=>{e.forEach(e=>{0<e.intersectionRatio?(console.log(e,"active"),e.target.classList.add("bg-blue-800")):(console.log(e,"inactive"),e.target.classList.remove("bg-blue-800"))})},{root:null,threshold:.1});var o=[];[...document.querySelectorAll("#toc li a")].forEach(e=>{o.push(e.href.substring(e.href.indexOf("#")))});const e=document.querySelectorAll(o.join(","));e.forEach(e=>{t.observe(e)})}); |