From 367f989bebbe40714a864f12937fcc283e45be0b Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Sat, 24 May 2025 20:57:12 +0330 Subject: [PATCH] changed scroll to top logic --- 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 7a9bcd0..ada8613 100644 --- a/frontend/plugins/scrollToTop.client.ts +++ b/frontend/plugins/scrollToTop.client.ts @@ -1,5 +1,12 @@ export default defineNuxtPlugin((nuxtApp) => { + let previousPath: string | null = null; + nuxtApp.hook("page:finish", () => { - window.scrollTo(0, 0); + const currentPath = useRoute().fullPath; + + if (previousPath !== currentPath) { + window.scrollTo(0, 0); + previousPath = currentPath; + } }); });