This commit is contained in:
Thomas Chartron 2021-11-13 18:25:51 +01:00
parent 970412e902
commit 4ea8249ada
2 changed files with 2 additions and 2 deletions

View file

@ -164,7 +164,7 @@ document.addEventListener("DOMContentLoaded", function() {
// })
});
function setActiveToc(elements) {
elements.reverse();
// elements.reverse();
return [...elements].find((item) => {
return (item.getBoundingRect().y < 0)
})

View file

@ -1 +1 @@
function setActiveToc(e){return e.reverse(),[...e].find(e=>e.getBoundingRect().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("#")))});const o=document.querySelectorAll(n.join(","));console.log(o),window.addEventListener("scroll",()=>{!1===t?(e[0].classList.add("bg-blue-800"),t=e[0]):console.log(setActiveToc(o))})});
function setActiveToc(e){return[...e].find(e=>e.getBoundingRect().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("#")))});const o=document.querySelectorAll(n.join(","));console.log(o),window.addEventListener("scroll",()=>{!1===t?(e[0].classList.add("bg-blue-800"),t=e[0]):console.log(setActiveToc(o))})});