Skip to content

Commit

Permalink
refactor: remove deprecated usage of pageXOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 11, 2023
1 parent b7f59db commit 66a6f54
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/router/src/scrollBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type ScrollPositionCoordinates = {

/**
* Internal normalized version of {@link ScrollPositionCoordinates} that always
* has `left` and `top` coordinates.
* has `left` and `top` coordinates. Must be a type to be assignable to HistoryStateValue.
*
* @internal
*/
Expand Down Expand Up @@ -68,11 +68,10 @@ function getElementPosition(
}
}

export const computeScrollPosition = () =>
({
left: window.pageXOffset,
top: window.pageYOffset,
} as _ScrollPositionNormalized)
export const computeScrollPosition = (): _ScrollPositionNormalized => ({
left: window.scrollX,
top: window.scrollY,
})

export function scrollToPosition(position: ScrollPosition): void {
let scrollToOptions: ScrollPositionCoordinates
Expand Down Expand Up @@ -146,8 +145,8 @@ export function scrollToPosition(position: ScrollPosition): void {
window.scrollTo(scrollToOptions)
else {
window.scrollTo(
scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset,
scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset
scrollToOptions.left != null ? scrollToOptions.left : window.scrollX,
scrollToOptions.top != null ? scrollToOptions.top : window.scrollY
)
}
}
Expand Down

0 comments on commit 66a6f54

Please sign in to comment.