diff --git a/src/js/page.js b/src/js/page.js index 3e7da21..382e0b0 100644 --- a/src/js/page.js +++ b/src/js/page.js @@ -18,7 +18,13 @@ document.addEventListener("DOMContentLoaded", function() { // console.log(entry.intersectionRatio) console.log('entry', entry) console.log('current', current_intersectiong_entry) - if (entry.isIntersecting) { + if (current_intersectiong_entry !== null && current_intersectiong_entry.isIntersecting === false) { + //Previous entry not intersecting anymore remove class and find the new one + let res = findCorrespondingTocTitle(current_intersectiong_entry.target) + current_selected_toc.parentElement.classList.remove('bg-blue-800'); + current_intersectiong_entry = null + } + if (entry.isIntersecting && current_intersectiong_entry === null) { console.log('processing') if (current_intersectiong_entry !== null && current_intersectiong_entry.target.getBoundingClientRect().y > 0) { console.log('stop')