mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +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) => {
|
const scrollBehavior = (to, from, savedPosition) => {
|
||||||
|
// savedPosition is only available for popstate navigations.
|
||||||
if (savedPosition) {
|
if (savedPosition) {
|
||||||
// savedPosition is only available for popstate navigations.
|
|
||||||
return savedPosition
|
return savedPosition
|
||||||
} else {
|
} else {
|
||||||
let position = {}
|
let position = {}
|
||||||
// if no children detected
|
// if no children detected
|
||||||
if (to.matched.length < 2) {
|
if (to.matched.length < 2) {
|
||||||
|
// scroll to the top of the page
|
||||||
position = { x: 0, y: 0 }
|
position = { x: 0, y: 0 }
|
||||||
}
|
}
|
||||||
else if (to.matched.some((r) => r.components.default.options.scrollToTop)) {
|
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 }
|
position = { x: 0, y: 0 }
|
||||||
}
|
}
|
||||||
// if link has anchor, scroll to anchor by returning the selector
|
// if link has anchor, scroll to anchor by returning the selector
|
||||||
|
Loading…
Reference in New Issue
Block a user