blow/static/js/page.js
Thomas Chartron ec5073d3f4 update
2021-11-13 14:02:56 +01:00

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)})});