changed scroll to top logic

This commit is contained in:
Mamalizz
2025-05-24 20:57:12 +03:30
parent ce31f2350c
commit 367f989beb
+8 -1
View File
@@ -1,5 +1,12 @@
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
let previousPath: string | null = null;
nuxtApp.hook("page:finish", () => { nuxtApp.hook("page:finish", () => {
window.scrollTo(0, 0); const currentPath = useRoute().fullPath;
if (previousPath !== currentPath) {
window.scrollTo(0, 0);
previousPath = currentPath;
}
}); });
}); });