diff --git a/frontend/plugins/scrollToTop.client.ts b/frontend/plugins/scrollToTop.client.ts index ada8613..7b4587f 100644 --- a/frontend/plugins/scrollToTop.client.ts +++ b/frontend/plugins/scrollToTop.client.ts @@ -1,11 +1,18 @@ export default defineNuxtPlugin((nuxtApp) => { let previousPath: string | null = null; + let isFirstLoad = true; nuxtApp.hook("page:finish", () => { const currentPath = useRoute().fullPath; + if (isFirstLoad) { + previousPath = currentPath; + isFirstLoad = false; + return; + } + if (previousPath !== currentPath) { - window.scrollTo(0, 0); + window.scrollTo({ top: 0, behavior: "auto" }); previousPath = currentPath; } });