Skip to content

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

Toolkitsparkles:ui: components as pure per-frame functions over const state (UI-Q1)
Animation primitivesnone general; three hand-written integrators (ScrollMotion, ScrollbarAnim, the dock's pane bars) and a frame-counted spinner
State lives inthe application's or the component's own struct, stepped in place; ElementStore holds scroll state
Time sourcea dt in seconds the caller passes to step/animate; 0 on a target with no frame clock
Frame requestsHostState.requestFrame (one more frame, re-asked every frame) and wakeIn (a deadline)
Reduced motionTargetCapabilities.reducedMotion (ACC5); honoured by ScrollMotion.instant only where a consumer sets it
SpecsSCV12, SCV13 (scroll motion, overlay bar), LYR10 (a closing overlay paints without hits), WGT5 (animation phase lives in the per-element store)

What moves today ​

MotionTypeStateIntegratorEnds
Smooth scroll, wheel or keyScrollMotion (SCV12)pos, target, velocity, modecritically damped spring, solved exactly over the step (step)abs(x) < 0.01 → settle()
FlingScrollMotionsameexponential decay, velocity *= exp(-flingFriction * dt)below minFlingSpeed, or at an edge
Scrollbar hover-expand and touch fadeScrollbarAnim (SCV13)percent, visibleforward-Euler ease, percent += (target - percent) * 15 * dt, then clampedclamp at 0 or 100
Scroll body (motion plus fade)ScrollBody.animateowns a ScrollMotion and an OverlayBarcomposes the two; returns true "while the motion or the fade needs the next" frameboth idle
Dock pane bars and capture autoscrollDock.tickScrollthe dock's own arraysper-pane dt stepno capture
SpinnerspinnerFrame (progress.d)a caller-held size_t framea glyph per frame, cycling every 10never (the caller stops asking)
Overlay exitOverlaySpec.closing (LYR10)a bool the component sets while it keeps building the overlaynone in the toolkit: the application runs the fade and stops building the overlay when it endsthe 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 springSeconds without 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, ScrollView and DocViewPane hold their motion as fields and mutate it in animate(dt). The application owns the struct and calls animate before 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 it requires" through a ref, 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.retain sweeps 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 each requestFrame. 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 ​

CapabilityStatus 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 animationpartial — LYR10 paints a closing overlay; the application drives the fade and the unbuild
Layout (geometry) animation✗
Reduced motionpartial — reducedMotion is a capability; only ScrollMotion.instant honours it, set by hand
Deterministic time in testspartial — 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 ​