mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
add rooter restore scroll state when using navigator return/next buttons
This commit is contained in:
parent
64c6aefe63
commit
d309610f44
1 changed files with 17 additions and 2 deletions
|
@ -8,7 +8,23 @@ Vue.use(VueRouter)
|
|||
const router = new VueRouter({
|
||||
// mode: 'history', // this allow all routes to be real ones (without '#')
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
routes,
|
||||
|
||||
scrollBehavior (to, from, savedPosition) {
|
||||
// Mimics the native scroll behavior of the browser.
|
||||
// This allows the user to find his way back to the scroll level of the previous/next route.
|
||||
|
||||
// if animations are enabled, we need to delay a bit the returned value of the saved
|
||||
// scroll state because the component probably hasn't updated the window height yet.
|
||||
// Note: this will only work with routes that use stored data or that has static content
|
||||
if (store.getters.transitions && savedPosition) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => resolve(savedPosition), 0)
|
||||
})
|
||||
} else {
|
||||
return savedPosition || { x: 0, y: 0 }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
|
@ -17,7 +33,6 @@ router.beforeEach((to, from, next) => {
|
|||
next()
|
||||
} else {
|
||||
store.dispatch('DISCONNECT', to)
|
||||
// next({ name: 'login', query: { redirect: to.path } })
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue