From 7419f2a3fbdd6c67b0d027a4131054df3a2b594e Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 20 Oct 2019 21:40:44 +0200 Subject: [PATCH] Fixed scroll behaviour --- src/router/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index 4d538294d..4bf34ea24 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -27,6 +27,22 @@ Vue.use(Router) export default new Router({ mode: 'history', + scrollBehavior (to, from, savedPosition) { + // If the user is using their forward/backward keys to navigate, we want to restore the scroll view + if(savedPosition) { + return savedPosition + } + + // Scroll to anchor should still work + if(to.hash) { + return { + selector: to.hash + } + } + + // Otherwise just scroll to the top + return { x: 0, y: 0 } + }, routes: [ { path: '/',