MCPcopy Index your code
hub / github.com/codeaashu/claude-code / useAnimationFrame

Function useAnimationFrame

src/ink/hooks/use-animation-frame.ts:30–57  ·  view source on GitHub ↗
(
  intervalMs: number | null = 16,
)

Source from the content-addressed store, hash-verified

28 * so consumers don't need to handle focus state.
29 */
30export function useAnimationFrame(
31 intervalMs: number | null = 16,
32): [ref: (element: DOMElement | null) => void, time: number] {
33 const clock = useContext(ClockContext)
34 const [viewportRef, { isVisible }] = useTerminalViewport()
35 const [time, setTime] = useState(() => clock?.now() ?? 0)
36
37 const active = isVisible && intervalMs !== null
38
39 useEffect(() => {
40 if (!clock || !active) return
41
42 let lastUpdate = clock.now()
43
44 const onChange = (): void => {
45 const now = clock.now()
46 if (now - lastUpdate >= intervalMs!) {
47 lastUpdate = now
48 setTime(now)
49 }
50 }
51
52 // keepAlive: true — visible animations drive the clock
53 return clock.subscribe(onChange, true)
54 }, [clock, intervalMs, active])
55
56 return [viewportRef, time]
57}
58

Callers 11

TeleportProgressFunction · 0.85
TextInputFunction · 0.85
BriefSpinnerFunction · 0.85
SpinnerFunction · 0.85
SpinnerAnimationRowFunction · 0.85
useShimmerAnimationFunction · 0.85
AnimatedAsteriskFunction · 0.85
HighlightedInputFunction · 0.85
ProcessingShimmerFunction · 0.85
ReviewRainbowLineFunction · 0.85
useBlinkFunction · 0.85

Calls 1

useTerminalViewportFunction · 0.85

Tested by

no test coverage detected