Repository navigation
chore(core): the animator plays any closed-form curve - #8521
Merged
Merged
Conversation
Touch presentations get one native-feeling behavior by default on every touch device, iOS and Android alike: measured values, compositor motion a finger can catch, recognizer-tracked gestures with native arbitration, two press profiles, and a Reduce Motion cross-fade. Touch motion is themeable, with the measured values as theme defaults; gesture thresholds stay internal. Size keys on the spec:AST-012 FR9 compact definition, a moved default is restored by the caller's presentation choice (INV16, DEC-23), and the record names the current claims it amends. Platform look and feel (OQ3) and module-level experimental subpaths (OQ4) stay open. Co-authored-by: vjeux <[email protected]>
Springs, scroll physics, timing curves, navigation values and gesture thresholds for the touch presentations of core components, each with its source (Apple documentation, a WWDC session, WebKit's UIKit-matched source, or a measurement of UIKit on the iOS 26.2 simulator) or labelled a guess with its measurement task. A test enforces the source rules on every domain file, in their JSDoc and typed forms, and checks the list of simulator measurements still owed.
Pure functions for the touch presentations: a closed-form damped spring with every Apple parameterization and Core Animation's settling duration, a spring chasing a moving target, UIScrollView's coast, rubber band and release projection. Tests hold them to an RK4 integration, WebKit's spring solver, the WWDC conversion equations and values read from UIKit, and play the constants table through them.
createAnimator plays springs and UIScrollView coasts as Web Animations keyframes on translate, rotate, scale and opacity, on one explicit clock, so they keep running while JavaScript is busy. Presentation values and velocities come from the curves, so a finger can catch any animation and a new target keeps the velocity; the end state is committed inline and held by the keyframes through a main-thread block, and a finished animation retires when its own time reaches the curve's end, so a sampler can pause it; Reduce Motion substitutes UIKit's cross-fade.
…ery measurement Review fixes: the table headers point at uikit.test.ts and MEASUREMENTS.md (not a sources.test.ts or the README); the springs header says how many springs are guesses (two) instead of most; gestures.ts no longer names the gesture system that arrives later; MEASUREMENTS.md keeps the switch and context-menu captures open until their tables land; the switch springs say they are WebKit's iOS 18 values, not UIKit's frames. Every measured source now carries its date, and uikit.test.ts refuses one without.
selectSnapPoint built its search window from fromIndex unclamped, so a stale current page past the end gave an empty window and value undefined. The index is clamped to the points first.
A move under Reduce Motion that named no opacity ended its cross-fade at the opacity on screen, so a move during a fade left the element mid-fade for good (0.55 instead of 0 after a fade-out). The fade now ends where the running curve was heading.
…tarts at the commit
play() bakes curves given as value and velocity functions of time (a spring
chasing a moving target, a fitted UIKit curve) like a spring.
createAnimator(dialog, {pseudoElement: '::backdrop'}) drives a
pseudo-element: a static filling animation holds its end value.
animatorFor(element) shares one animator per element, so callers animating
different axes compose in one translate track; atRest() waits out every
curve on its properties, and rebase() moves them by a layout shift keeping
their springs. A call from rest gets no start time, so the browser starts it
at its commit, as Core Animation does, and handle.started reports that
start. Every animation and set() promotes its channels to a compositing
layer in the same task (will-change, or a host custom property for a
pseudo-element) until 500 ms after the last motion: Mobile Safari only runs
a script-started curve through a block on an element that already has a
layer. Under Reduce Motion the substituted cross-fade can follow a
presentation's own spring, and crossfadeAs gives a slide that changes no
opacity its direction. The header lists the iOS Safari limits measured on
the simulator.
Every write went through format(), so a motion back to identity left translate: 0px 0px (or scale: 1) inline. Any translate but none makes the element the containing block of its position: fixed descendants (a fixed bar moved with its parent), and Mobile Safari lets no finger scroll a list inside an element left at scale: 1. An identity is now written none (opacity 1), and once no animation runs on its channel it is removed, unless the stylesheet would then move the element. The keyframes stay numeric.
…er starts it Review fixes for the commit-time start: - A curve whose call the browser has not started yet reads at its start: nothing has moved on screen, so a retarget before the first frame (after a block) continues from there instead of from where the clock says. - A call whose curves a later same-task call took over resolves started with that call's start, not its own call time. - A channel rebuilt by set, rebase or another axis while one of its curves waits for the browser's start keeps that start; rebasing such a curve keeps it in its call (and in the call's segments). - dispose() settles every atRest() wait and its timer. - Under Reduce Motion, 'instant' leaves an opacity the call does not name alone, and a removed segment is read before it goes. - The test header no longer names a browser spec that does not exist.
Under prefers-reduced-motion: reduce, every animate and play is replaced and
nothing moves, scales or springs (DR1). On a coarse primary pointer, or for a
call a touch drag's release starts (touchRelease), it is an opacity-only
cross-fade of 200 ms on Core Animation's easeInOut (DR2): an entrance lands
and fades in, an exit fades out and then lands, an opacity change fades, and
any other move dips (fades out, lands while transparent with a plain style
write, fades back in). On any other pointer the change completes at once
(DR3). The reducedMotion option ('crossfade' | 'instant' | 'keep') and the
crossfade spring are gone, and no option lengthens the fade (DR4);
crossfadeAs only orients a slide that changes no opacity. Landings survive a
second call in the same frame, a later call reads where opacity is heading
past a waiting dip, and only a call's own opacity makes it an entrance or an
exit. reducedMotionFade() answers the same policy for motion the animator
does not drive, and reducedMotion.stylex.ts holds its CSS constants; both are
internal. A decay keeps its motion: it only continues a finger's throw.
It also carries the held-start fixes: a held curve's velocity is the one the
model has reached (a flick's held moves keep their speed), a call on the clock
of a waiting call from rest joins it, and a time ahead reads a waiting curve
from its provisional start.
These are the changes that rode in #8076 (63e5356, 18ff410, 9fff2ac,
65ac34a, 49bb28a, 0b81c86, 970c908, 5cb103f), now where the animator
introduces Reduce Motion.
The animator and reducedMotionFade() read the person's settings (prefers-reduced-motion and a coarse primary pointer) and nothing else: the prefersReducedMotion and isCoarsePointer options are gone, so no caller can keep the motion or change which form it takes (design:reduced-motion DR4), and the experimental motion surface adds no Reduce Motion override. Tests set the settings through matchMedia. Co-authored-by: vjeux <[email protected]>
UIKIT_GESTURES shipped each value's provenance as runtime strings
({value, unit, source} or {value, unit, guess, measure}): 69% of the minified
module, carried by every page that reads a gesture threshold, and read by
nothing at run time. Its entries now carry their sources as JSDoc tags
(@source, @measure), like every other domain of the table, and ship only
{value, unit}. Values and units are unchanged; isGuess and the sourced and
guessed constant types go, since no value carries a guess any more.
The haptic stand-ins share one guess, stated once above
HAPTIC_VIBRATION_PATTERNS, and the patterns are plain literals, so a bundle
that never plays a haptic drops them. uikit.test.ts checks gestures.ts in the
JSDoc form, fails a table value named source, guess or measure, and checks
the haptic block; gestures.test.ts checks that each constant ships only its
value and unit.
Production bundle, minified and gzipped: UIKIT_GESTURES alone 5,794 B /
2,397 B -> 1,746 B / 785 B (scroll and timing included); a Carousel built on
the gesture system 63,389 -> 61,489 B gzip; the gesture host alone 16,320 ->
14,434 B gzip.
The touch-presentations record is revised in its own pull request; this stack keeps no copy of it.
… into the constants table
Every caller of the animator shipped UIScrollView's coast (decay.ts) and the
scroll table, though only a surface that coasts reads them. The coast moves
to coast.ts: coast(animator, velocity, {bounds, rate, bounce, at}) builds a
release's momentum curves from the presentation values, and
animator.decay(curves, {at}) plays them as given. Reduced Motion still does
not apply to a coast (a throw continues the finger), and each curve, edge
hand-off and spring-back is the same as before.
The coast tests move to coast.test.ts and play through decay in
animator.test.ts, with the Reduced Motion case and a check that the animator
imports neither the coast math nor the scroll table.
Production bundle, gzip: createAnimator alone 5,377 -> 4,794 B; with coast
5,515 B.
spec:AST-094 FR4 names every touch motion role for its use. The 13 platform presets in the constants table keep their values and sources and take those names: springs smooth, snappy, bouncy, interactive, uikitDefault, uikitSpringDuration, swiftUIDefault and swiftUISpring become settle, quickChange, emphasis, fingerTracking, viewChange, timedChange, stateChange and directChange; timing.implicitAnimationMs becomes stateChangeMs; and the curves caDefault, easeInOut, easeIn and easeOut become viewChange, move, exit and entrance. The source names stay in each entry's JSDoc. A test pins the use names, their values, and the absence of the source names.
The only conflict was the stack's draft copy of docs/specs/AST-094-touch-presentations/spec.md; main's merged record (23de092) replaces it.
…, and its press clocks import alone - gestures.ts imports the press clocks by name (DELAYS_CONTENT_TOUCHES_MS, press), so reading one threshold no longer bundles the scroll and timing tables (component-style-authoring INV6). - Drops the least-squares velocity rows (AST-100 FR2: one release filter) and scroll.contentEndHandoffSlop (AST-094 FR14), with their measurement tasks. - Marks timing.reducedMotionCrossFadeMs and springs.menuReducedMotion as reference readings a touch presentation does not play (AST-094 FR8). - uikit.test.ts checks every exported table group and rejects a provenance key in any value; the README and JSDoc stop citing code and rules that do not exist (decay.ts, toSpring, law P1/P2) and say components read touch motion from the theme's roles (AST-094 FR4).
press.highlightOutCurve is the highlight fade's curve after release, beside highlightOutMs: cubic-bezier(0, 0, 0.2, 1), the release curve the touch press model ships with. It is a guess until M-PR1 reads the timing function Core Animation attaches to the deselect fade.
# Conflicts: # docs/specs/AST-094-touch-presentations/spec.md
- A write later in the task (set, rebase, another axis) that rebuilds a channel whose curve still waits for its call's start samples the new keyframes from that call's own time, which the browser's start moves: the screen and get() stay on one clock however long the task ran between the call and the write. - When such a write cancels the animation the call waited on, the call follows one of its animations still playing instead of resolving at its call time, so it still starts with the browser's commit. Tests: a write 100 ms later in the task; a write whose cancel rejects before the first frame.
UIKit's two-event filter keeps the last moving value after a pause; the note now says so as UIKit's behavior and that Astryx's release reads 0 once the finger has rested (spec:AST-100 FR2), so the table no longer reads as Astryx's rule.
Contributor
There was a problem hiding this comment.
Recommending approval: with #8056 landed, this is the 461-line play() change plus the unmount-landing fix, and both match the current touch-presentation and Reduce Motion specs. The tests cover the played curve's keyframes, read-back and Reduce Motion forms, and the new unmount tests fail without the fix. Nothing else is needed; since the description and changeset mention only play(), consider naming the unmount fix there too.
[Automated review]
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
Main's meta#8521 is its head 25b468c squashed, which this pull request already carries: every file it touches is byte-identical to 25b468c. In the two files that conflicted (the motion README and animator.ts), the resolution is this side's version, main's merged meta#8521 with this pull request's later work on top. Nothing of main is dropped.
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
4 tasks done
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
4 tasks done
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
4 tasks done
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
…README's file names The motion README's Files table takes main's rows (the animator plays any closed-form curve; the Reduce Motion planner) and keeps this side's rows for roles.ts and roleValue.ts.
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
…d notification export Main's timing table keeps the Reduce Motion fade's own export, now 200 ms with its new reasoning (design:reduced-motion DR2's cap, DEC-1). This side composes the table's own-export groups from plain constants, so a bundle that reads only the keyboard's duration drops the rest of the table: the fade's constant takes main's value and comment. The keyboard bundle test now looks for the fade's 200 ms; with main's destructured composition it fails, finding the fade in a keyboard-only bundle.
4 tasks done
vjeux
added a commit
to vjeux/astryx
that referenced
this pull request
Oct 27, 2026
meta#8521) into the input hold
This was referenced Oct 27, 2026
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #8056 (and its predecessors); review this pull request's own commit (the last one).
Split out of #8056 so each animator capability is reviewed on its own.
User need
A touch presentation sometimes follows a curve that is not a plain spring: a press that keeps deepening while held (a spring chasing a moving target), or a fitted UIKit curve. It needs to run on the compositor like a spring, so it keeps moving while JavaScript is busy.
Problem and solution fit
animator.play(curves)bakes any curve given as value and velocity functions of time, exactly like a spring: presentation values, velocities,stop,finishedand the shared clock work the same, and a lateranimatestarts from the curve's value and velocity.design:reduced-motionDR2, DR3), as foranimate.Current specification
spec:AST-094FR5, FR6, FR8;design:reduced-motionDR1–DR4.Public delta and caller burden
None: internal and unused; the changeset is
[chore].Design and alternatives
Evidence
animate, duration 0, an invalid duration, Reduce Motion on both pointers, and rebasing a curve that waits for its first frame.Writing rubric results
No record text of its own: AST-094 is current on
main; R1–R6: none.Scope
Testing
vitest run --project ui packages/core/src/motion packages/core/src/gestures: passed.tsc --noEmitforpackages/core, eslint, prettier,check:changesets,check:sync: clean.