mirror of
https://github.com/tchartron/blow
synced 2024-11-27 06:40:31 +00:00
update
This commit is contained in:
parent
ed0c1bb4b2
commit
57b8be5d78
2 changed files with 3 additions and 3 deletions
|
@ -22,12 +22,12 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
// console.log('here')
|
||||
if (current_selected_toc !== null) {
|
||||
// console.log(res)
|
||||
current_selected_toc.classList.remove('bg-blue-800');
|
||||
current_selected_toc.parentElement.classList.remove('bg-blue-800');
|
||||
}
|
||||
current_selected_toc = res
|
||||
}
|
||||
// console.log(res)
|
||||
res.classList.add('bg-blue-800');
|
||||
res.parentElement.classList.add('bg-blue-800');
|
||||
} else {
|
||||
// has_one_active_toc = false
|
||||
// console.log(entry, 'inactive')
|
||||
|
|
|
@ -1 +1 @@
|
|||
function findCorrespondingTocTitle(t){return[...document.querySelectorAll("#toc li a")].find(e=>e.href.substring(e.href.indexOf("#"))==="#"+t.id)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");var e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let n=null;const t=new window.IntersectionObserver(e=>{e.forEach(t=>{if(t.isIntersecting){console.log(t,"active");let e=findCorrespondingTocTitle(t.target);void 0===e||null!==n&&n===e||(null!==n&&n.classList.remove("bg-blue-800"),n=e),e.classList.add("bg-blue-800")}})},{root:null,threshold:.1});var o=[];[...e].forEach(e=>{o.push(e.href.substring(e.href.indexOf("#")))});const l=document.querySelectorAll(o.join(","));l.forEach(e=>{t.observe(e)})});
|
||||
function findCorrespondingTocTitle(t){return[...document.querySelectorAll("#toc li a")].find(e=>e.href.substring(e.href.indexOf("#"))==="#"+t.id)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");var e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let n=null;const t=new window.IntersectionObserver(e=>{e.forEach(t=>{if(t.isIntersecting){console.log(t,"active");let e=findCorrespondingTocTitle(t.target);void 0===e||null!==n&&n===e||(null!==n&&n.parentElement.classList.remove("bg-blue-800"),n=e),e.parentElement.classList.add("bg-blue-800")}})},{root:null,threshold:.1});var o=[];[...e].forEach(e=>{o.push(e.href.substring(e.href.indexOf("#")))});const l=document.querySelectorAll(o.join(","));l.forEach(e=>{t.observe(e)})});
|
Loading…
Reference in a new issue