Fixed scroll behaviour
This commit is contained in:
parent
0af1deaa00
commit
7419f2a3fb
1 changed files with 16 additions and 0 deletions
|
@ -27,6 +27,22 @@ Vue.use(Router)
|
||||||
|
|
||||||
export default new Router({
|
export default new Router({
|
||||||
mode: 'history',
|
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: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|
Loading…
Reference in a new issue