Skip to content

Commit

Permalink
scroll back to top on navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey committed Nov 27, 2023
1 parent e1f60b8 commit 55c2ea3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@
showNavigationLoadingBar = true;
});
afterNavigate(() => {
afterNavigate((params) => {
showNavigationLoadingBar = false;
documentTitle = document?.title;
disabled = titleDisabledUrls.find((url) => $page.url.pathname === url) !== undefined;
// scroll to top
const isNewPage = params.from?.url.pathname !== params.to?.url.pathname;
const elemPage = document.querySelector("#page");
if (isNewPage && elemPage !== null) {
elemPage.scrollTop = 0;
}
});
initializeStores();
Expand Down

0 comments on commit 55c2ea3

Please sign in to comment.