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

Function useHeroDeadZone

packages/shared/src/components/shell/usePassedBlock.ts:54–82  ·  view source on GitHub ↗
(
  ref: RefObject<HTMLElement>,
  enabled = true,
)

Source from the content-addressed store, hash-verified

52// so the name, Follow and the segments are seen arriving in it on the way
53// down instead of only on a scroll back up.
54export const useHeroDeadZone = (
55 ref: RefObject<HTMLElement>,
56 enabled = true,
57): void => {
58 useEffect(() => {
59 const element = ref.current;
60 if (!enabled || !element) {
61 return undefined;
62 }
63
64 const measure = () =>
65 setShellDeadZone(
66 element.getBoundingClientRect().bottom +
67 window.scrollY +
68 scroll.heroDeadZone,
69 );
70 measure();
71 const observer =
72 typeof ResizeObserver === 'undefined'
73 ? undefined
74 : new ResizeObserver(measure);
75 observer?.observe(element);
76
77 return () => {
78 observer?.disconnect();
79 setShellDeadZone();
80 };
81 }, [ref, enabled]);
82};

Callers 4

TagTopicPageFunction · 0.90
SquadProfileHeaderFunction · 0.90
ProfilePageFunction · 0.90
SourceShellPageFunction · 0.90

Calls 2

setShellDeadZoneFunction · 0.90
measureFunction · 0.70

Tested by

no test coverage detected