MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / handleResize

Function handleResize

src/ts-default/Components/CardNav/CardNav.tsx:115–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114 useLayoutEffect(() => {
115 const handleResize = () => {
116 if (!tlRef.current) return;
117
118 if (isExpanded) {
119 const newHeight = calculateHeight();
120 gsap.set(navRef.current, { height: newHeight });
121
122 tlRef.current.kill();
123 const newTl = createTimeline();
124 if (newTl) {
125 newTl.progress(1);
126 tlRef.current = newTl;
127 }
128 } else {
129 tlRef.current.kill();
130 const newTl = createTimeline();
131 if (newTl) {
132 tlRef.current = newTl;
133 }
134 }
135 };
136
137 window.addEventListener('resize', handleResize);
138 return () => window.removeEventListener('resize', handleResize);

Callers

nothing calls this directly

Calls 2

calculateHeightFunction · 0.70
createTimelineFunction · 0.70

Tested by

no test coverage detected