Skip to content

Commit 4e0b3e0

Browse files
gaetansennposva
andauthored
feat(scroll): dd behavior support on scrollBehavior (#3351)
Co-authored-by: Eduardo San Martin Morote <[email protected]>
1 parent fdc5d78 commit 4e0b3e0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/util/scroll.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ function scrollToPosition (shouldScroll, position) {
160160
}
161161

162162
if (position) {
163-
window.scrollTo(position.x, position.y)
163+
// $flow-disable-line
164+
if ('scrollBehavior' in document.documentElement.style) {
165+
window.scrollTo({
166+
left: position.x,
167+
top: position.y,
168+
// $flow-disable-line
169+
behavior: shouldScroll.behavior
170+
})
171+
} else {
172+
window.scrollTo(position.x, position.y)
173+
}
164174
}
165175
}

types/router.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface NavigationFailure extends Error {
8686
}
8787

8888
type Position = { x: number; y: number }
89-
type PositionResult = Position | { selector: string; offset?: Position } | void
89+
type PositionResult = Position | { selector: string; offset?: Position, behavior?: ScrollBehavior } | void
9090

9191
export interface RouterOptions {
9292
routes?: RouteConfig[]

0 commit comments

Comments
 (0)