fix smooth scroll bug

This commit is contained in:
Cory LaViska
2024-12-17 12:09:45 -05:00
parent d09ea4a73a
commit 9979028d7e

View File

@@ -1,13 +1,14 @@
// Smooth links
document.addEventListener('click', event => {
const link = event.target.closest('a');
const id = (link?.hash ?? '').substr(1);
if (!link || link.getAttribute('data-smooth-link') === 'off') {
return;
}
if (id) {
const id = (link.hash ?? '').substr(1);
// Only handle smooth scroll if there's a hash and the link points to the current page
if (id && link.pathname === window.location.pathname) {
const target = document.getElementById(id);
const headerHeight = document.querySelector('wa-page > header').clientHeight;