mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
Improve comments
This commit is contained in:
parent
f3719add05
commit
4cbd6d6a28
@ -27,16 +27,18 @@ const <%= route._name %> = process.BROWSER_BUILD ? () => System.import('<%= rout
|
||||
<% }) %>
|
||||
|
||||
const scrollBehavior = (to, from, savedPosition) => {
|
||||
if (savedPosition) {
|
||||
// savedPosition is only available for popstate navigations.
|
||||
if (savedPosition) {
|
||||
return savedPosition
|
||||
} else {
|
||||
let position = {}
|
||||
// if no children detected
|
||||
if (to.matched.length < 2) {
|
||||
// scroll to the top of the page
|
||||
position = { x: 0, y: 0 }
|
||||
}
|
||||
else if (to.matched.some((r) => r.components.default.options.scrollToTop)) {
|
||||
// if one of the children has scrollToTop option set to true
|
||||
position = { x: 0, y: 0 }
|
||||
}
|
||||
// if link has anchor, scroll to anchor by returning the selector
|
||||
|
Loading…
Reference in New Issue
Block a user