mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
fix smooth scroll bug
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user