Sparkles baseline — what animates in sparkles:ui today
The system this survey informs: sparkles:ui and its host, sparkles:ui-app. This page states what already moves, where its state lives, who supplies the time, and how a frame is asked for — the facts the comparison measures the surveyed systems against.
Last reviewed: November 26, 2026
| Toolkit | sparkles:ui: components as pure per-frame functions over const state (UI-Q1) |
| Animation primitives | none general; three hand-written integrators (ScrollMotion, ScrollbarAnim, the dock's pane bars) and a frame-counted spinner |
| State lives in | the application's or the component's own struct, stepped in place; ElementStore holds scroll state |
| Time source | a dt in seconds the caller passes to step/animate; 0 on a target with no frame clock |
| Frame requests | HostState.requestFrame (one more frame, re-asked every frame) and wakeIn (a deadline) |
| Reduced motion | TargetCapabilities.reducedMotion (ACC5); honoured by ScrollMotion.instant only where a consumer sets it |
| Specs | SCV12, SCV13 (scroll motion, overlay bar), LYR10 (a closing overlay paints without hits), WGT5 (animation phase lives in the per-element store) |
What moves today
| Motion | Type | State | Integrator | Ends |
|---|---|---|---|---|
| Smooth scroll, wheel or key | ScrollMotion (SCV12) | pos, target, velocity, mode | critically damped spring, solved exactly over the step (step) | abs(x) < 0.01 → settle() |
| Fling | ScrollMotion | same | exponential decay, velocity *= exp(-flingFriction * dt) | below minFlingSpeed, or at an edge |
| Scrollbar hover-expand and touch fade | ScrollbarAnim (SCV13) | percent, visible | forward-Euler ease, percent += (target - percent) * 15 * dt, then clamped | clamp at 0 or 100 |
| Scroll body (motion plus fade) | ScrollBody.animate | owns a ScrollMotion and an OverlayBar | composes the two; returns true "while the motion or the fade needs the next" frame | both idle |
| Dock pane bars and capture autoscroll | Dock.tickScroll | the dock's own arrays | per-pane dt step | no capture |
| Spinner | spinnerFrame (progress.d) | a caller-held size_t frame | a glyph per frame, cycling every 10 | never (the caller stops asking) |
| Overlay exit | OverlaySpec.closing (LYR10) | a bool the component sets while it keeps building the overlay | none in the toolkit: the application runs the fade and stops building the overlay when it ends | the application stops building it |
ScrollMotion's header states the design:
"The easing is a critically damped spring, the shape Neovide scrolls with: it reaches its target in about
springSecondswithout overshooting, and a new notch moves the target without throwing the velocity away, so notches in quick succession add up to one smooth glide." (scroll_motion.d)
That one sentence already holds three of the survey's findings: a spring rather than a duration, retargeting that keeps velocity (what SwiftUI, Compose and Motion do by default), and the exact closed-form step ("solved exactly over the step, so a long frame cannot overshoot"), which makes the result independent of the frame rate. ScrollbarAnim has none of these: its Euler step changes with dt, and a frame longer than 1/15 s overshoots and is caught only by the clamp.
Where the state lives
There is no single answer yet, which is the gap this survey addresses:
- In the component's own struct, stepped in place.
ScrollBody,ScrollViewandDocViewPanehold their motion as fields and mutate it inanimate(dt). The application owns the struct and callsanimatebefore the frame's view. - In an
ElementStore, for scroll state keyed by element identity (WGT5): "scroll offsets, focus and animation phase survive a view rebuild because identity — not equality — decides which element is "the same one" across frames." Today a view "steps the state itrequires" through aref, so the view writes the store. The component-authoring decisions (UI-Q5) move this to a store the component reads and the host commits after layout, which forbids that write. ElementStore.retainsweeps every entry whose element is not in the new tree. An element's presentation state therefore dies in the frame the element is first not built — exactly when an exit animation would need it (UI-Q10).
Who owns the clock
The toolkit never reads a clock. Every integrator takes dt from its caller; easeVertical in the gallery documents the convention: "dtSeconds of zero means the target has no frame clock — a terminal wakes on input" (scrollbars.d). The host has two time facts it could hand the view but does not yet:
FrameStart.target, the predicted presentation time of the frame being built (OPL13–OPL17). Sampling an animation at the frame's presentation time rather than at its start is what Compose's frame clock ("normalized to the target time for the frame") and Core Animation's display link do (Compose, Core Animation).- The recorder (
record.d) drives an application from a script with no window (TST1–TST3) and records eachrequestFrame. It is the natural home for a virtual clock, which it does not have yet.
How a frame is asked for
HostState.requestFrame is the only animation hook the host has, and its contract is the one the survey recommends:
"It is a request for one frame, not a mode: a continuing animation asks again each time, so a finished one stops costing anything without having to remember to turn itself off."
Every integrator above returns a bool "still moving" for its caller to turn into that request, the shape egui's animate_bool gives automatically (immediate mode). The terminal arm blocks on input and wakes on a request or on wakeIn, so an idle terminal costs nothing.
Gaps the survey measures
| Capability | Status today |
|---|---|
| A general value animation (tween or spring) | ✗ — each motion is hand-written |
| Animation as data, sampled at a time | ✗ — every integrator mutates state by dt |
| Frame-rate independence | ✓ ScrollMotion (exact step); ✗ ScrollbarAnim (Euler) |
| Retargeting keeps velocity | ✓ ScrollMotion.nudge; n/a elsewhere |
| Presentation state keyed by identity | ✓ ElementStore (WGT5), but written by the view |
| Exit animation | partial — LYR10 paints a closing overlay; the application drives the fade and the unbuild |
| Layout (geometry) animation | ✗ |
| Reduced motion | partial — reducedMotion is a capability; only ScrollMotion.instant honours it, set by hand |
| Deterministic time in tests | partial — dt is an argument, so a unit test passes one; no virtual clock in the recorder |
| Frames only while animating | ✓ requestFrame is one-shot by contract |
Sources
libs/ui/src/sparkles/ui/scroll_motion.d—ScrollMotion,MotionMode,step,nudge,flinglibs/ui/src/sparkles/ui/components/scroll_view.d—ScrollbarAnim,stepFade,fadinglibs/ui/src/sparkles/ui/components/scroll_body.d—ScrollBody.animatelibs/ui/src/sparkles/ui/components/dock.d—tickScrolllibs/ui/src/sparkles/ui/components/progress.d—spinnerFramelibs/ui/src/sparkles/ui/state.d—ElementStore,require,retainlibs/ui/src/sparkles/ui/overlay/arena.d—OverlaySpec.closinglibs/ui/src/sparkles/ui/tokens.d—TargetCapabilities.reducedMotionlibs/ui-app/src/sparkles/ui_app/host.d—requestFrame,wakeInlibs/ui-app/src/sparkles/ui_app/frame_schedule.d—FrameStartlibs/ui-app/src/sparkles/ui_app/record.d— the recording hostapps/ui-gallery/src/scrollbars.d—easeVertical- Specs: containers (
SCV12,SCV13), popup (LYR10), widgets (WGT5); decisions UI-Q1–UI-Q7; open questions UI-Q9 and UI-Q10 in PR #775