Skip to content

Commit

Permalink
toc_container might not exist, e.g. http://127.0.0.1:1314/spin-000Z.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Jul 11, 2024
1 parent 73870ee commit eb5c0ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/uts-forester.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ document.addEventListener("DOMContentLoaded", function () {

if (!entry.isIntersecting && toc_entry && !toc_entry.parentElement.querySelector(`ul li`)) {
console.log("Scrolling out of view", entry.target, entry.intersectionRatio, entry.isIntersecting, entry);
toc_entry.closest("li").parentElement.closest("li").classList.remove('active');
const toc_container = toc_entry.closest("li").parentElement.closest("li")
if(toc_container) toc_container.classList.remove('active');
content_out_of_sight_observer.unobserve(entry.target);
}
});
Expand Down Expand Up @@ -95,7 +96,8 @@ document.addEventListener("DOMContentLoaded", function () {
const toc_entry = document.querySelector(`nav#toc [data-target="#${id}"]`);

if (toc_entry && !toc_entry.parentElement.querySelector(`ul li`)) {
toc_entry.closest("li").parentElement.closest("li").classList.add('active');
const toc_container = toc_entry.closest("li").parentElement.closest("li")
if(toc_container) toc_container.classList.add('active');
toc_out_of_sight_observer.observe(toc_entry);
}
// else {
Expand Down

0 comments on commit eb5c0ef

Please sign in to comment.