diff --git a/src/util/scroll.js b/src/util/scroll.js index d12461e99..d1adeb310 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -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) + } } } diff --git a/types/router.d.ts b/types/router.d.ts index b587bf3e1..ec48c7dca 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -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[]