MCPcopy Create free account
hub / github.com/adobe/react-spectrum / restoreScrollPosition

Function restoreScrollPosition

packages/dev/s2-docs/src/client.tsx:48–60  ·  view source on GitHub ↗
(state: HistoryState | null)

Source from the content-addressed store, hash-verified

46}
47
48function restoreScrollPosition(state: HistoryState | null) {
49 if (state?.scrollTop != null || state?.windowScrollTop != null) {
50 requestAnimationFrame(() => {
51 let scrollContainer = getScrollContainer();
52 if (scrollContainer && state.scrollTop != null) {
53 scrollContainer.scrollTop = state.scrollTop;
54 }
55 if (state.windowScrollTop != null) {
56 window.scrollTo(0, state.windowScrollTop);
57 }
58 });
59 }
60}
61
62// A very simple router. When we navigate, we'll fetch a new RSC payload from the server,
63// and in a React transition, stream in the new page. Once complete, we'll pushState to

Callers 1

navigateFunction · 0.70

Calls 1

getScrollContainerFunction · 0.85

Tested by

no test coverage detected