mirror of
https://github.com/tchartron/blow
synced 2024-11-23 21:03:16 +00:00
update
This commit is contained in:
parent
c86e017547
commit
4cfb6d09ce
2 changed files with 5 additions and 2 deletions
|
@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
entries.some(entry => {
|
||||
console.log('before')
|
||||
console.log('entry', entry)
|
||||
// console.log('current', current_intersectiong_entry)
|
||||
console.log('current', current_intersectiong_entry.getboundingClientRect().y < 0)
|
||||
|
||||
if (entry.isIntersecting && (current_intersectiong_entry === null || current_intersectiong_entry.target.getboundingClientRect().y < 0)) {
|
||||
let res = findCorrespondingTocTitle(entry.target)
|
||||
|
@ -22,6 +22,9 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
current_intersectiong_entry = entry
|
||||
return true;
|
||||
}
|
||||
console.log('after')
|
||||
console.log('entry', entry)
|
||||
console.log('current', current_intersectiong_entry.getboundingClientRect().y < 0)
|
||||
if (!entry.isIntersecting) {
|
||||
let res = findCorrespondingTocTitle(entry.target) //First intersection entry
|
||||
res.parentElement.classList.remove('bg-blue-800');
|
||||
|
|
|
@ -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");const t=new window.IntersectionObserver(e=>{e.some(t=>{if(console.log("before"),console.log("entry",t),t.isIntersecting){let e=findCorrespondingTocTitle(t.target);return e.parentElement.classList.add("bg-blue-800"),!0}if(!t.isIntersecting){let e=findCorrespondingTocTitle(t.target);return e.parentElement.classList.remove("bg-blue-800"),e.parentElement.nextElementSibling.classList.add("bg-blue-800"),!0}})},{root:null,threshold:.1});var n=[];[...e].forEach(e=>{n.push(e.href.substring(e.href.indexOf("#")))});const o=document.querySelectorAll(n.join(","));o.forEach(e=>{t.observe(e)})});
|
||||
function findCorrespondingTocTitle(n){return[...document.querySelectorAll("#toc li a")].find(e=>e.href.substring(e.href.indexOf("#"))==="#"+n.id)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");var e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let t=null;const n=new window.IntersectionObserver(e=>{e.some(n=>{if(console.log("before"),console.log("entry",n),console.log("current",t.getboundingClientRect().y<0),n.isIntersecting&&(null===t||t.target.getboundingClientRect().y<0)){let e=findCorrespondingTocTitle(n.target);return e.parentElement.classList.add("bg-blue-800"),t=n,!0}if(console.log("after"),console.log("entry",n),console.log("current",t.getboundingClientRect().y<0),!n.isIntersecting){let e=findCorrespondingTocTitle(n.target);return e.parentElement.classList.remove("bg-blue-800"),e.parentElement.nextElementSibling.classList.add("bg-blue-800"),!0}})},{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=>{n.observe(e)})});
|
Loading…
Reference in a new issue