primevue-mirror/middleware/route.global.js

10 lines
330 B
JavaScript
Raw Normal View History

2022-12-28 09:32:27 +00:00
export default defineNuxtRouteMiddleware((to, from) => {
useNuxtApp().hook('page:finish', () => {
if (to.path !== from.path && history.state.scroll) {
setTimeout(() => window.scrollTo(history.state.scroll), 0);
} else {
setTimeout(() => window.scrollTo(0, 0), 0);
}
});
});