Skip to content

Commit 66a6f54

Browse files
committed
refactor: remove deprecated usage of pageXOffset
1 parent b7f59db commit 66a6f54

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/router/src/scrollBehavior.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type ScrollPositionCoordinates = {
1616

1717
/**
1818
* Internal normalized version of {@link ScrollPositionCoordinates} that always
19-
* has `left` and `top` coordinates.
19+
* has `left` and `top` coordinates. Must be a type to be assignable to HistoryStateValue.
2020
*
2121
* @internal
2222
*/
@@ -68,11 +68,10 @@ function getElementPosition(
6868
}
6969
}
7070

71-
export const computeScrollPosition = () =>
72-
({
73-
left: window.pageXOffset,
74-
top: window.pageYOffset,
75-
} as _ScrollPositionNormalized)
71+
export const computeScrollPosition = (): _ScrollPositionNormalized => ({
72+
left: window.scrollX,
73+
top: window.scrollY,
74+
})
7675

7776
export function scrollToPosition(position: ScrollPosition): void {
7877
let scrollToOptions: ScrollPositionCoordinates
@@ -146,8 +145,8 @@ export function scrollToPosition(position: ScrollPosition): void {
146145
window.scrollTo(scrollToOptions)
147146
else {
148147
window.scrollTo(
149-
scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset,
150-
scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset
148+
scrollToOptions.left != null ? scrollToOptions.left : window.scrollX,
149+
scrollToOptions.top != null ? scrollToOptions.top : window.scrollY
151150
)
152151
}
153152
}

0 commit comments

Comments
 (0)