Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
afterNavigate(() => {
current = location.hash.slice(1);
headings = content.querySelectorAll('h2');
update(); // Ensure active link is set correctly on navigation
setTimeout(() => update(), 0); // Delay to allow layout to settle
});

// Update function to activate the correct section link
function update() {
const threshold = (innerHeight * 1) / 3;

// If scrolled less than threshold, activate the page title
if (scrollY < threshold) {
current = '';
return;
}

let found = false;

for (let i = 0; i < headings.length; i++) {
Expand All @@ -33,10 +40,7 @@
}
}

// Handle case when scrolled to the top of the page
if (!found && scrollY === 0) {
current = '';
}
// If no heading found, keep current as is
}
</script>

Expand Down