MCPcopy Create free account
hub / github.com/dailydotdev/apps / getScrollKey

Function getScrollKey

packages/shared/src/lib/scrollRestoration.ts:12–20  ·  view source on GitHub ↗
(asPath: string, kind: ScrollPositionKind)

Source from the content-addressed store, hash-verified

10let activeRestoration: (() => void) | undefined;
11
12const getScrollKey = (asPath: string, kind: ScrollPositionKind): string => {
13 if (typeof window === 'undefined') {
14 return `${kind}:${asPath}`;
15 }
16
17 const url = new URL(asPath, window.location.origin);
18 const historyKey = (window.history.state as { key?: string } | null)?.key;
19 return `${kind}:${url.pathname}${url.search}${url.hash}:${historyKey ?? ''}`;
20};
21
22export const getHistoryEntryKey = (): string =>
23 getScrollKey(window.location.href, 'page');

Callers 3

getHistoryEntryKeyFunction · 0.85
getScrollPositionFunction · 0.85
saveScrollPositionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected