Skip to content

Commit ab215a8

Browse files
committed
avoid using sessionStorage for saving scroll position (fix #813)
1 parent a8902fb commit ab215a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/util/scroll-position.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
/* @flow */
22

3+
const positionStore = Object.create(null)
4+
35
export function saveScrollPosition (key: string) {
46
if (!key) return
5-
window.sessionStorage.setItem(key, JSON.stringify({
7+
positionStore[key] = {
68
x: window.pageXOffset,
79
y: window.pageYOffset
8-
}))
10+
}
911
}
1012

1113
export function getScrollPosition (key: string): ?Object {
1214
if (!key) return
13-
return JSON.parse(window.sessionStorage.getItem(key))
15+
return positionStore[key]
1416
}
1517

1618
export function getElementPosition (el: Element): Object {

0 commit comments

Comments
 (0)