···108108seconds since the previous render. That value is passed to the layout
109109engine to advance any in-flight transitions.
110110111111+If the previous render reported `animating=false`, the Term passes
112112+`deltaTime=0` to the layout engine on the current render, regardless of
113113+wall-clock time elapsed. The rationale: Clay is delta-based and has no
114114+concept of when a transition began. Idle time between renders must not
115115+count toward any subsequent transition's elapsed clock, otherwise a long
116116+idle gap followed by a mutation would cause the transition to complete
117117+instantly. Passing `deltaTime=0` on the first frame of any new transition
118118+gives it a clean elapsed=0 starting point; real deltas resume once the
119119+previous render signals `animating=true`.
120120+111121The caller MAY override the computed delta via an explicit `deltaTime`
112122option on `render()`. Use cases include deterministic testing, snapshot
113123rendering, and compute-only renders where the caller is querying bounds
···209219210220Each `render()` call advances transitions by its `deltaTime`:
211221212212-- If `deltaTime` is omitted, Term computes it as the monotonic wall-clock
213213- time elapsed since the previous `render()` call.
214214-- If `deltaTime` is provided, it is used verbatim for that frame.
222222+- If `deltaTime` is provided explicitly, it is used verbatim.
223223+- Otherwise, if the previous render reported `animating=false`,
224224+ `deltaTime=0` (see §4.2 for rationale).
225225+- Otherwise, `deltaTime` is the monotonic wall-clock time elapsed since
226226+ the previous `render()` call.
215227216228On every `render()` call, Term captures the current monotonic timestamp as
217229the reference point for the next implicit delta. The two modes can be
+5-2
term.ts
···8181 let pressed = new Set<string>();
8282 let wasDown = false;
8383 let lastRenderAt: number | undefined;
8484+ let wasAnimating = false;
84858586 return {
8687 render(ops: Op[], options?: RenderOptions): RenderResult {
···9192 let dt: number;
9293 if (options?.deltaTime !== undefined) {
9394 dt = options.deltaTime;
9494- } else if (lastRenderAt === undefined) {
9595+ } else if (!wasAnimating || lastRenderAt === undefined) {
9596 dt = 0;
9697 } else {
9798 dt = now - lastRenderAt;
···165166 });
166167 }
167168168168- return { output, events, info, errors, animating: native.animating(statePtr) > 0 };
169169+ let animating = native.animating(statePtr) > 0;
170170+ wasAnimating = animating;
171171+ return { output, events, info, errors, animating };
169172 },
170173 };
171174}