Skip to content

Commit

Permalink
scroll back to top on navigate (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey authored Nov 29, 2023
1 parent b2d14f8 commit 3ae2062
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 @@ -33,10 +33,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 3ae2062

Please sign in to comment.