From fb6e026588517fac0dea7824fae40adc7f4b1fb7 Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Wed, 4 Jun 2025 19:14:22 +0330 Subject: [PATCH] added first loading check for scroll top --- frontend/plugins/scrollToTop.client.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } });