Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ const router = new Router({
},
},
],
scrollBehavior (to, from, savedPosition) {
// brings viewport back to where it was when using Back button
if (savedPosition) return savedPosition

// scroll to in-page router-link anchor if used
if (to.hash) {
return { selector: to.hash, behavior: 'smooth' }
}

// default: scroll to the top of the page
return { x: 0, y: 0, behavior: 'smooth' }
},
})

// Require some routes to be logged in only.
Expand Down
Loading