Skip to content

Commit

Permalink
fix(scroll): avoid reusing scroll position
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 24, 2020
1 parent 07100fc commit dfc1fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/router.ts
Expand Up @@ -652,6 +652,7 @@ export function createRouter(options: RouterOptions): Router {
pendingLocation = toLocation
const from = currentRoute.value

// TODO: should be moved to web history?
if (isBrowser) {
saveScrollPosition(
getScrollKey(from.fullPath, info.delta),
Expand Down
5 changes: 4 additions & 1 deletion src/scrollBehavior.ts
Expand Up @@ -123,7 +123,10 @@ export function saveScrollPosition(
}

export function getSavedScrollPosition(key: string) {
return scrollPositions.get(key)
const scroll = scrollPositions.get(key)
// consume it so it's not used again
scrollPositions.delete(key)
return scroll
}

// TODO: RFC about how to save scroll position
Expand Down

0 comments on commit dfc1fb3

Please sign in to comment.