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

Function holdScroll

packages/shared/src/components/shell/ExploreSortMenu.tsx:52–70  ·  view source on GitHub ↗
(
  router: NextRouter,
  position: number,
  href: string,
)

Source from the content-addressed store, hash-verified

50// the document is short for a moment. The reader's place is put back once
51// the new page has grown to it, instead of leaving them above the rows.
52const holdScroll = (
53 router: NextRouter,
54 position: number,
55 href: string,
56): void => {
57 let letGo = () => undefined;
58 const restore = (url: string) => {
59 letGo();
60 if (url.split(/[?#]/)[0] === href) {
61 restoreScrollPosition(position);
62 }
63 };
64 letGo = () => {
65 router.events.off('routeChangeComplete', restore);
66 router.events.off('routeChangeError', letGo);
67 };
68 router.events.on('routeChangeComplete', restore);
69 router.events.on('routeChangeError', letGo);
70};
71
72export function ExploreSortMenu(): ReactElement {
73 const router = useRouter();

Callers 1

ExploreSortMenuFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected