From dbe762d71c5bbc6af75cfcb744bb3ab7dba2eacd Mon Sep 17 00:00:00 2001 From: wvffle Date: Thu, 30 Jun 2022 03:37:03 +0000 Subject: [PATCH] Fix scrollBehavior --- front/src/router/index.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/front/src/router/index.ts b/front/src/router/index.ts index 9ed669f44..3e4cfe7fa 100644 --- a/front/src/router/index.ts +++ b/front/src/router/index.ts @@ -32,22 +32,21 @@ console.log('PROCESS', import.meta.env) export default createRouter({ history: createWebHistory(import.meta.env.VUE_APP_ROUTER_BASE_URL as string ?? '/'), linkActiveClass: 'active', - // TODO (wvffle): uncomment - // scrollBehavior (to, from, savedPosition) { - // if (to.meta.preserveScrollPosition) { - // return savedPosition ?? { left: 0, top: 0 } - // } + scrollBehavior (to, from, savedPosition) { + if (to.meta.preserveScrollPosition) { + return savedPosition ?? { left: 0, top: 0 } + } - // return new Promise(resolve => { - // setTimeout(() => { - // if (to.hash) { - // resolve({ el: to.hash, behavior: 'smooth' }) - // } + return new Promise(resolve => { + setTimeout(() => { + if (to.hash) { + resolve({ el: to.hash, behavior: 'smooth' }) + } - // resolve(savedPosition ?? { left: 0, top: 0 }) - // }, 100) - // }) - // }, + resolve(savedPosition ?? { left: 0, top: 0 }) + }, 100) + }) + }, routes: [ { path: '/',