Skip to content

Commit

Permalink
feat(scroll): allow modifying scrollBehavior in options (#602)
Browse files Browse the repository at this point in the history
this allows enhanceApp in vuepress to run after creating the router
  • Loading branch information
posva committed Nov 21, 2020
1 parent 4fcf59e commit d6651f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export function createRouter(options: RouterOptions): Router {
const matcher = createRouterMatcher(options.routes, options)
let parseQuery = options.parseQuery || originalParseQuery
let stringifyQuery = options.stringifyQuery || originalStringifyQuery
let { scrollBehavior } = options
let routerHistory = options.history

const beforeGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
Expand All @@ -345,7 +344,7 @@ export function createRouter(options: RouterOptions): Router {
let pendingLocation: RouteLocation = START_LOCATION_NORMALIZED

// leave the scrollRestoration if no scrollBehavior is provided
if (isBrowser && scrollBehavior && 'scrollRestoration' in history) {
if (isBrowser && options.scrollBehavior && 'scrollRestoration' in history) {
history.scrollRestoration = 'manual'
}

Expand Down Expand Up @@ -1016,6 +1015,7 @@ export function createRouter(options: RouterOptions): Router {
isPush: boolean,
isFirstNavigation: boolean
): Promise<any> {
const { scrollBehavior } = options
if (!isBrowser || !scrollBehavior) return Promise.resolve()

let scrollPosition: _ScrollPositionNormalized | null =
Expand Down

0 comments on commit d6651f5

Please sign in to comment.