MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / preventLayoutShift

Function preventLayoutShift

apps/baseai.dev/src/components/Code.tsx:267–282  ·  view source on GitHub ↗
(callback: () => void)

Source from the content-addressed store, hash-verified

265 return {
266 positionRef,
267 preventLayoutShift(callback: () => void) {
268 if (!positionRef.current) {
269 return;
270 }
271
272 let initialTop = positionRef.current.getBoundingClientRect().top;
273
274 callback();
275
276 rafRef.current = window.requestAnimationFrame(() => {
277 let newTop =
278 positionRef.current?.getBoundingClientRect().top ??
279 initialTop;
280 window.scrollBy(0, newTop - initialTop);
281 });
282 }
283 };
284}
285

Callers 1

useTabGroupPropsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected