mirror of
https://github.com/tchartron/blow
synced 2024-11-24 05:13:08 +00:00
update
This commit is contained in:
parent
2eb0672f7b
commit
5125de93f3
2 changed files with 3 additions and 3 deletions
|
@ -20,9 +20,9 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
console.log('reprocess')
|
console.log('reprocess')
|
||||||
}
|
}
|
||||||
if (entry.isIntersecting) {
|
if (entry.isIntersecting) {
|
||||||
console.log('intersecting')
|
console.log('processing')
|
||||||
console.log('entry', entry)
|
console.log('entry', entry)
|
||||||
// console.log('current', current_intersectiong_entry)
|
console.log('current', current_intersectiong_entry)
|
||||||
if (current_intersectiong_entry !== null) {
|
if (current_intersectiong_entry !== null) {
|
||||||
console.log('current', current_intersectiong_entry.target.getBoundingClientRect().y)
|
console.log('current', current_intersectiong_entry.target.getBoundingClientRect().y)
|
||||||
// console.log('should stop')
|
// console.log('should stop')
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
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,o=null;const n=new window.IntersectionObserver(e=>{e.forEach(n=>{if(console.log("observe"),(null===o||o.target.getBoundingClientRect().y<0)&&console.log("reprocess"),n.isIntersecting){console.log("intersecting"),console.log("entry",n),null!==o&&console.log("current",o.target.getBoundingClientRect().y);let e=findCorrespondingTocTitle((o=n).target);void 0===e||null!==t&&t===e||(null!==t&&t.parentElement.classList.remove("bg-blue-800"),t=e),e.parentElement.classList.add("bg-blue-800")}})},{root:null,threshold:.1});var l=[];[...e].forEach(e=>{l.push(e.href.substring(e.href.indexOf("#")))});const r=document.querySelectorAll(l.join(","));r.forEach(e=>{n.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,o=null;const n=new window.IntersectionObserver(e=>{e.forEach(n=>{if(console.log("observe"),(null===o||o.target.getBoundingClientRect().y<0)&&console.log("reprocess"),n.isIntersecting){console.log("processing"),console.log("entry",n),console.log("current",o),null!==o&&console.log("current",o.target.getBoundingClientRect().y);let e=findCorrespondingTocTitle((o=n).target);void 0===e||null!==t&&t===e||(null!==t&&t.parentElement.classList.remove("bg-blue-800"),t=e),e.parentElement.classList.add("bg-blue-800")}})},{root:null,threshold:.1});var l=[];[...e].forEach(e=>{l.push(e.href.substring(e.href.indexOf("#")))});const r=document.querySelectorAll(l.join(","));r.forEach(e=>{n.observe(e)})});
|
Loading…
Reference in a new issue