MCPcopy Create free account
hub / github.com/Roy3838/Observer / loop

Function loop

app/src/components/EditAgent/SimpleCreatorTutorial.tsx:34–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32 let scrolled = false;
33 let rafId: number;
34 const loop = () => {
35 const el = document.querySelector(cfg.selector);
36 if (el) {
37 setRect(el.getBoundingClientRect());
38 if (!scrolled) {
39 const r = el.getBoundingClientRect();
40 // Only scroll when the element's panel is actually visible horizontally
41 if (r.left < window.innerWidth && r.right > 0) {
42 const panel = el.closest('.overflow-y-auto') as HTMLElement | null;
43 if (panel) {
44 const elTop = r.top - panel.getBoundingClientRect().top + panel.scrollTop;
45 panel.scrollTo({ top: elTop - panel.clientHeight / 2 + (el as HTMLElement).offsetHeight / 2, behavior: 'smooth' });
46 }
47 scrolled = true;
48 }
49 }
50 }
51 rafId = requestAnimationFrame(loop);
52 };
53 rafId = requestAnimationFrame(loop);
54 return () => cancelAnimationFrame(rafId);
55 }, [cfg?.selector]);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected