Skip to content

Commit

Permalink
fix(scroll): only apply on browser
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Apr 15, 2020
1 parent 181efe9 commit cf53192
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// import { RouteLocationNormalized } from '../types'

import { isBrowser } from './env'

export type ScrollToPosition = {
x: number
y: number
Expand Down Expand Up @@ -73,9 +75,8 @@ export function scrollToPosition(position: ScrollPosition): void {
export const scrollPositions = new Map<string, ScrollToPosition>()

export function getScrollKey(path: string, distance: number): string {
const position: number = history.state
? history.state.position - distance
: -1
const position: number =
isBrowser && history.state ? history.state.position - distance : -1
return position + path
}

Expand Down

0 comments on commit cf53192

Please sign in to comment.