This commit is contained in:
Thomas Chartron 2021-11-13 15:55:22 +01:00
parent d1463d3fc9
commit c644b56495

View file

@ -18,7 +18,13 @@ document.addEventListener("DOMContentLoaded", function() {
// console.log(entry.intersectionRatio) // console.log(entry.intersectionRatio)
console.log('entry', entry) console.log('entry', entry)
console.log('current', current_intersectiong_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') console.log('processing')
if (current_intersectiong_entry !== null && current_intersectiong_entry.target.getBoundingClientRect().y > 0) { if (current_intersectiong_entry !== null && current_intersectiong_entry.target.getBoundingClientRect().y > 0) {
console.log('stop') console.log('stop')