Skip to content

Commit 7af81ec

Browse files
committed
fix scroll issue for anchor links
1 parent 4b81e7e commit 7af81ec

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/client/scroll-fix.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
export function onRouteDidUpdate({ location, previousLocation }) {
2+
if (!previousLocation && location.hash) {
3+
return;
4+
}
5+
if (previousLocation &&
6+
location.pathname === previousLocation.pathname &&
7+
location.hash) {
8+
return;
9+
}
210
function handleScroll() {
311
const items = document.querySelectorAll('.menu__link--active')
412
if (items?.length === 0) return

0 commit comments

Comments
 (0)