Skip to content

Commit

Permalink
feat(scroll): dd behavior support on scrollBehavior (#3351)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
  • Loading branch information
gaetansenn and posva committed Oct 21, 2020
1 parent fdc5d78 commit 4e0b3e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/util/scroll.js
Expand Up @@ -160,6 +160,16 @@ function scrollToPosition (shouldScroll, position) {
}

if (position) {
window.scrollTo(position.x, position.y)
// $flow-disable-line
if ('scrollBehavior' in document.documentElement.style) {
window.scrollTo({
left: position.x,
top: position.y,
// $flow-disable-line
behavior: shouldScroll.behavior
})
} else {
window.scrollTo(position.x, position.y)
}
}
}
2 changes: 1 addition & 1 deletion types/router.d.ts
Expand Up @@ -86,7 +86,7 @@ export interface NavigationFailure extends Error {
}

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

export interface RouterOptions {
routes?: RouteConfig[]
Expand Down

0 comments on commit 4e0b3e0

Please sign in to comment.