Better route transitions
This commit is contained in:
@@ -9,18 +9,36 @@ const router = createRouter({
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: HomeView,
|
||||
meta: { transition: '' },
|
||||
},
|
||||
{
|
||||
path: '/daily',
|
||||
name: 'daily',
|
||||
component: () => import('../views/GameView.vue'),
|
||||
meta: { transition: 'route' },
|
||||
},
|
||||
{
|
||||
path: '/random',
|
||||
name: 'random',
|
||||
component: () => import('../views/GameView.vue'),
|
||||
meta: { transition: 'route' },
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
router.afterEach((to, from) => {
|
||||
// No transition when direct access
|
||||
if (!from.name) {
|
||||
to.meta.transition = ''
|
||||
}
|
||||
// Back animation when going back to home
|
||||
else if (to.path === '/') {
|
||||
to.meta.transition = 'route_back'
|
||||
}
|
||||
// Normal forward animation
|
||||
else {
|
||||
to.meta.transition = 'route'
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user