We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8902fb commit ab215a8Copy full SHA for ab215a8
src/util/scroll-position.js
@@ -1,16 +1,18 @@
1
/* @flow */
2
3
+const positionStore = Object.create(null)
4
+
5
export function saveScrollPosition (key: string) {
6
if (!key) return
- window.sessionStorage.setItem(key, JSON.stringify({
7
+ positionStore[key] = {
8
x: window.pageXOffset,
9
y: window.pageYOffset
- }))
10
+ }
11
}
12
13
export function getScrollPosition (key: string): ?Object {
14
- return JSON.parse(window.sessionStorage.getItem(key))
15
+ return positionStore[key]
16
17
18
export function getElementPosition (el: Element): Object {
0 commit comments