Skip to content

Commit

Permalink
preserve scroll on initial page load
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Jan 15, 2025
1 parent 9e97591 commit b81f8f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/initialVisit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class InitialVisit {
currentPage.setUrlHash(window.location.hash)
}

currentPage.set(currentPage.get(), { preserveState: true }).then(() => {
currentPage.set(currentPage.get(), { preserveScroll: true, preserveState: true }).then(() => {
fireNavigateEvent(currentPage.get())
})
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ class CurrentPage {
this.isFirstPageLoad = false

return this.swap({ component, page, preserveState }).then(() => {
if (!preserveScroll) {
Scroll.reset()
}
preserveScroll ? Scroll.restore(history.getScrollRegions()) : Scroll.reset()

eventHandler.fireInternalEvent('loadDeferredProps')

Expand Down

0 comments on commit b81f8f9

Please sign in to comment.