An open source design system that's fully customizable and agent ready
TypeScript
chore(core): the animator plays any closed-form curve (#8521)
Cindy Zhanga00afee502eb
diff --git a/.changeset/uikit-motion-animator-curves.md b/.changeset/uikit-motion-animator-curves.mdnew file mode 100644index 0000000000..86bc609560--- /dev/null+++ b/.changeset/uikit-motion-animator-curves.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[chore] Internal: the touch presentations' animator plays any closed-form curve (such as a spring chasing a moving target) through `play`, with the same presentation values, velocities, stop and shared clock as a spring, and the Reduce Motion policy. Not exported from the package entry point.++@vjeuxdiff --git a/packages/core/src/motion/README.md b/packages/core/src/motion/README.mdindex e25d5c6346..aa3f609c00 100644--- a/packages/core/src/motion/README.md+++ b/packages/core/src/motion/README.md@@ -26,7 +26,7 @@ so each keeps its measured value; no shipped component reads the roles yet.| `rubberBand.ts` | UIScrollView's resistance past an edge, and its inverse. || `projection.ts` | Release targets: the rest point nearest the projected coast; paging. || `bezier.ts` | Cubic-bézier timing functions (Core Animation's named curves). |-| `animator.ts` | Compositor animator: springs and coasts compiled to Web Animations, read back analytically. |+| `animator.ts` | Compositor animator: springs, coasts and any closed-form curve compiled to Web Animations, read back analytically. || `reducedMotionPlan.ts` | The animator's Reduce Motion planner: what one call becomes, a cross-fade whose travel lands while transparent or at once. |Component-specific values (a sheet's detents, a switch's geometry, a context@@ -38,6 +38,7 @@ under the same rules.```import {createAnimator} from '../motion/animator';import {coast} from '../motion/coast';+import {solveSpringTowardRamp, toSpring} from '../motion/spring';import {springs} from '../motion/uikit';const animator = createAnimator(sheet);@@ -56,6 +57,18 @@ animator.stop(['y']); // freezes at the value on screen// A throw on a scroll-like surface, with an edge (coast.ts builds the curves):animator.decay(coast(animator, {x: velocityX}, {bounds: {x: {min: -maxScroll, max: 0}}}));+// Any closed-form curve, here a press that keeps deepening: the target+// scale falls at 0.16/s and the platter follows it on a spring. Press+// feedback has no fade of its own, so it is skipped under Reduce Motion.+if (animator.reducedMotion() === 'off') {+ const ramp = solveSpringTowardRamp(toSpring(springs.contextMenuLift), {+ from: 1,+ target: 1,+ slope: -0.16,+ });+ animator.play({scale: {duration: 0.266, at: ramp.value, velocity: ramp.velocity}});+}+await handle.finished; // true if it ran to the end, false if interrupted```@@ -71,6 +84,9 @@ await handle.finished; // true if it ran to the end, false if interruptedcurve ends, whoever started it.- `rebase({y: -shift})` moves properties at once, as a layout shift does; aproperty moving on a spring keeps its spring, velocity and target.+- `play` bakes any curve given as value and velocity functions of time (a+ spring chasing a moving target from `solveSpringTowardRamp`, a fitted UIKit+ curve) exactly like a spring.- `animate` always starts from the presentation value with the presentationvelocity unless a velocity is handed in, so retargeting is continuous(`handle.retarget(to)` keeps the call's spring).@@ -81,7 +97,7 @@ await handle.finished; // true if it ran to the end, false if interrupted(`handle.started`); a retarget keeps an explicit one, and `{at}` putsseveral animators on one clock.- Reduced Motion (`prefers-reduced-motion: reduce`, design:reduced-motion):- every `animate` is replaced and nothing moves, scales or+ every `animate` and `play` is replaced and nothing moves, scales orsprings. On a coarse primary pointer, or for a call started by a touchdrag's release (`{touchRelease: true}`), it is an opacity-only cross-fadeof `timing.reducedMotionCrossFadeMs` (200 ms): an entrance from 0 lands anddiff --git a/packages/core/src/motion/animator.test.ts b/packages/core/src/motion/animator.test.tsindex 5b71a32d7c..93a573ddc7 100644--- a/packages/core/src/motion/animator.test.ts+++ b/packages/core/src/motion/animator.test.ts@@ -28,7 +28,7 @@ import {import {cubicBezier} from './bezier';import {coast} from './coast';import {solveDecay} from './decay';-import {solveSpring, toSpring} from './spring';+import {solveSpring, solveSpringTowardRamp, toSpring} from './spring';import {scroll} from './uikit/scroll';import {springs} from './uikit/springs';import {timing} from './uikit/timing';@@ -649,6 +649,23 @@ describe('review fixes', () => {expect(vi.getTimerCount()).toBe(0);});+ it('rebasing a curve that waits for its first frame keeps it in its call', async () => {+ const {animator} = setup();+ animator.play({+ opacity: {duration: 0.3, at: t => 1 - t, velocity: () => -1},+ x: {duration: 0.3, at: t => 100 * t, velocity: () => 100},+ rotate: {duration: 0.3, at: t => 90 * t, velocity: () => 90},+ });+ animator.rebase({x: -20});+ animator.animate({y: 50}, {spring: springs.settle});+ clock = 1300;+ await commitFrame(1300);+ // Every curve starts with the browser's start.+ // 100 ms in: 9° (not the 27° of a curve dated at the call), x 10 − 20.+ expect(animator.get('rotate', 1400)).toBeCloseTo(9, 6);+ expect(animator.get('x', 1400)).toBeCloseTo(-10, 6);+ });+it('a rebase and a retarget in the task of a drop from rest start on the browser\u2019s clock', async () => {// A list row's drop: it springs home from where the finger left it.const {animator} = setup();@@ -1147,6 +1164,9 @@ describe('Reduced Motion (design:reduced-motion)', () => {{spring: springs.quickChange},{crossfadeAs: 'exit'},);+ animator.play({+ rotate: {duration: 0.3, at: t => 30 * t, velocity: () => 30},+ });await advance(1000);}expect(recorded.length).toBeGreaterThan(0);@@ -1329,6 +1349,68 @@ describe('Reduced Motion (design:reduced-motion)', () => {next.remove();});+ it('a node detached mid-dip and attached again in a later task shows the move landed and visible', async () => {+ const {animator, element} = reduced();+ // The call owns its opacity: its dip writes the low opacity inline.+ animator.animate({x: 240, opacity: 1}, {spring: springs.navigationPush});+ await advance(25);+ expect(Number(element.style.opacity)).toBeLessThan(1);+ animator.attach(null);+ await advance(100);+ animator.attach(element);+ expect(animator.get('x')).toBe(240);+ expect(animator.get('opacity')).toBe(1);+ expect(element.style.opacity).not.toBe('0');+ expect(Number(element.style.opacity || '1')).toBe(1);+ });++ it('a node detached mid-dip while another axis moves is left with no animation or promotion', async () => {+ const {animator, element} = reduced();+ animator.set({x: 0, y: 0});+ // y coasts (momentum keeps its motion) while x waits in a dip.+ const start = clock;+ animator.decay(coast(animator, {y: 800}, {at: start}), {at: start});+ animator.animate({x: 240}, {spring: springs.navigationPush});+ await advance(25);+ animator.attach(null);+ await advance(1);+ expect(+ recorded.filter(+ animation =>+ animation.element === element &&+ !animation.cancelled &&+ animation.playState !== 'finished',+ ),+ ).toEqual([]);+ expect(element.style.willChange).toBe('');+ });++ it('lands a waiting move on the latest node detached in the task, after a replacement too', async () => {+ const {animator} = reduced();+ animator.animate({x: 240, opacity: 1}, {spring: springs.navigationPush});+ await advance(25);+ const next = document.createElement('div');+ document.body.append(next);+ animator.attach(null);+ animator.attach(next);+ animator.attach(null);+ await advance(100);+ // The node attached last, then detached, is the one left visible.+ expect(Number(next.style.opacity || '1')).toBe(1);+ next.remove();+ });++ it('a dispose right after a detach lands the waiting move on that node', async () => {+ const {animator, element} = reduced();+ animator.animate({x: 240, opacity: 1}, {spring: springs.navigationPush});+ await advance(25);+ animator.attach(null);+ animator.dispose();+ await advance(100);+ expect(Number(element.style.opacity || '1')).toBe(1);+ expect(element.style.willChange).toBe('');+ });+it('an identity held over a differing stylesheet follows a node replacement', () => {const {animator, element} = reduced();stylesheet = {opacity: '0'};@@ -1818,7 +1900,10 @@ describe('Reduced Motion (design:reduced-motion)', () => {await commitFrame(clock);await advance(20);animator.attach(null);+ // The unmount is deferred to a microtask: read once it has run.+ await Promise.resolve();expect(element.style.willChange).toBe('');+ expect(vi.getTimerCount()).toBe(0);});it("a new element taking over an exit by role leaves the stylesheet's opacity on the outgoing one", async () => {@@ -2086,6 +2171,20 @@ describe('Reduced Motion (design:reduced-motion)', () => {);});+ it('a played curve, opacity alone included, becomes the timed fade', async () => {+ const {animator} = reduced();+ // A long dim that would follow a sheet's spring.+ animator.play({+ opacity: {duration: 0.6, at: t => 1 - t / 0.6, velocity: () => -1 / 0.6},+ });+ await commitFrame(clock); // the browser starts it+ expect(animator.get('opacity', 1000 + fade)).toBe(0);+ expect(Number(live('opacity')[0].options.duration)).toBeCloseTo(+ fade + END_HOLD_MS,+ 6,+ );+ });+it('a slide without opacity takes its direction from crossfadeAs', async () => {const entrance = reduced().animator;entrance.set({x: 300});@@ -2126,9 +2225,13 @@ describe('Reduced Motion (design:reduced-motion)', () => {it('completes at once on a fine pointer, opacity included', () => {const {animator} = reduced(false);animator.animate({x: 100, opacity: 0.5}, {spring: springs.navigationPush});+ animator.play({+ y: {duration: 0.4, at: t => 100 * t, velocity: () => 100},+ });expect(recorded).toHaveLength(0);expect(animator.get('x')).toBe(100);expect(animator.get('opacity')).toBe(0.5);+ expect(animator.get('y')).toBeCloseTo(40, 9);});it('fades on a fine pointer when a touch release started the call', async () => {@@ -2183,6 +2286,139 @@ describe('Reduced Motion (design:reduced-motion)', () => {});});+describe('play: any closed-form curve', () => {+ // A press that keeps deepening: the scale's target falls at 0.16 per+ // second and the presentation follows it on a spring.+ const pressSpring = toSpring(springs.contextMenuLift);+ const press = solveSpringTowardRamp(pressSpring, {+ from: 1,+ target: 1,+ slope: -0.16,+ });+ const pressCurve = {+ duration: 0.266,+ at: (t: number) => press.value(t),+ velocity: (t: number) => press.velocity(t),+ };++ it('bakes the curve into keyframes and reads it back', async () => {+ const {animator, element} = setup();+ animator.play({scale: pressCurve});+ const [animation] = live('scale');+ await commitFrame(1000);+ expect(animation.startTime).toBe(1000);+ expect(Number(animation.options.duration)).toBeCloseTo(+ 266 + END_HOLD_MS,+ 6,+ );+ // Up to the end: from then on the value rests where the curve ended.+ for (let t = 0; t < 266; t += 0.5) {+ const [sx, sy] = sampleAt(animation, 'scale', 1000 + t);+ expect(Math.abs(sx - press.value(t / 1000))).toBeLessThan(0.001);+ expect(sy).toBe(sx);+ expect(animator.get('scale', 1000 + t)).toBeCloseTo(+ press.value(t / 1000),+ 12,+ );+ expect(animator.getVelocity('scaleY', 1000 + t)).toBeCloseTo(+ press.velocity(t / 1000),+ 12,+ );+ }+ const end = press.value(0.266);+ expect(animator.get('scale', 1266)).toBeCloseTo(end, 12);+ expect(animator.getVelocity('scale', 1266)).toBe(0);+ for (const axis of parse(element.style.scale)) {+ expect(axis).toBeCloseTo(end, 4);+ }+ });++ it('finishes true at its end, false when interrupted', async () => {+ const {animator} = setup();+ const done = animator.play({+ x: {duration: 0.2, at: t => 100 * t, velocity: () => 100},+ });+ await advance(250);+ await expect(done.finished).resolves.toBe(true);+ const cut = animator.play({+ x: {duration: 0.2, at: t => 20 + 100 * t, velocity: () => 100},+ });+ await advance(50);+ animator.set({x: 0});+ await expect(cut.finished).resolves.toBe(false);+ });++ it('a later animate starts from the played value and velocity', async () => {+ const {animator} = setup();+ animator.play({scale: pressCurve});+ await advance(120);+ const value = animator.get('scale');+ const velocity = animator.getVelocity('scale');+ expect(value).toBeCloseTo(press.value(0.12), 12);+ animator.animate({scale: 1.06}, {spring: springs.contextMenuLift});+ expect(animator.get('scale')).toBeCloseTo(value, 9);+ expect(animator.getVelocity('scale')).toBeCloseTo(velocity, 9);+ });++ it('a zero-length curve puts the value in place', () => {+ const {animator, element} = setup();+ animator.play({opacity: {duration: 0, at: () => 0.4, velocity: () => 0}});+ expect(live('opacity')).toHaveLength(0);+ expect(animator.get('opacity')).toBe(0.4);+ expect(element.style.opacity).toBe('0.4');+ });++ it('under Reduced Motion a played travel cross-fades to its end', async () => {+ const reduced = setup({+ reduced: true,+ coarse: true,+ });+ reduced.animator.play({+ x: {duration: 0.3, at: t => 300 * t, velocity: () => 300},+ });+ await commitFrame(clock); // the browser starts it+ const [opacity] = live('opacity');+ expect(opacity).toBeDefined();+ expect(live('translate')).toHaveLength(0);+ await advance(timing.reducedMotionCrossFadeMs);+ expect(reduced.animator.get('x')).toBeCloseTo(90, 9);+ });++ it('its handle retargets only with a spring', () => {+ const {animator} = setup();+ const handle = animator.play({+ x: {duration: 0.3, at: t => 300 * t, velocity: () => 300},+ });+ expect(() => handle.retarget({x: 0})).toThrow(/spring/);+ handle.retarget({x: 0}, {spring: springs.settle});+ expect(animator.getVelocity('x')).toBeCloseTo(300, 9);+ });++ it('lets an explicit axis win over scale, in either order', () => {+ const {animator} = setup();+ const flat = (value: number) => ({+ duration: 0,+ at: () => value,+ velocity: () => 0,+ });+ animator.play({scaleY: flat(0.5), scale: flat(2)});+ expect(animator.get('scaleX')).toBe(2);+ expect(animator.get('scaleY')).toBe(0.5);+ animator.play({scale: flat(3), scaleX: flat(0.25)});+ expect(animator.get('scaleX')).toBe(0.25);+ expect(animator.get('scaleY')).toBe(3);+ });++ it('rejects a curve without a finite duration', () => {+ const {animator} = setup();+ expect(() =>+ animator.play({+ x: {duration: Number.POSITIVE_INFINITY, at: () => 0, velocity: () => 0},+ }),+ ).toThrow(RangeError);+ });+});+describe('decay: momentum curves (a coast)', () => {it('plays a coast and comes to rest where it projects', async () => {const {animator} = setup();diff --git a/packages/core/src/motion/animator.ts b/packages/core/src/motion/animator.tsindex 7114cbaddf..767dec344f 100644--- a/packages/core/src/motion/animator.ts+++ b/packages/core/src/motion/animator.ts@@ -16,8 +16,9 @@** Each animated value (x, y, rotate, scaleX, scaleY, opacity) follows a* closed-form curve: a spring (spring.ts), momentum curves its caller built (a- * UIScrollView coast with an edge bounce, coast.ts), or a Reduced Motion- * cross-fade. The curves are baked into Web Animations keyframes on the individual transform properties (`translate`,+ * UIScrollView coast with an edge bounce, coast.ts), a curve handed to `play` (a spring chasing a moving+ * target, a fitted UIKit curve), or a Reduced Motion cross-fade. The curves are baked into+ * Web Animations keyframes on the individual transform properties (`translate`,* `rotate`, `scale`) and `opacity`, sampled adaptively until linear* interpolation between keyframes is within a fraction of a pixel, and played* with `easing: linear`. The browser then runs them on its compositor: they@@ -91,7 +92,8 @@* into the curve (simulator, not yet confirmed on a device).** Reduced Motion (design:reduced-motion): with `prefers-reduced-motion:- * reduce`, every `animate` (travel or opacity) is replaced, and nothing moves, scales or springs. The planner+ * reduce`, every `animate` and `play` (travel or opacity, on a spring or any+ * curve) is replaced, and nothing moves, scales or springs. The planner* (reducedMotionPlan.ts) decides what each call becomes; the animator* applies the plan and runs its landings:* - on a coarse primary pointer, or for a call started by a touch drag's@@ -163,7 +165,7 @@ export interface SpringTransition {}/**- * Options of `animate`: the spring, a release velocity, the Reduced+ * Options of `animate` and `play`: the spring, a release velocity, the Reduced* Motion handling.*/export interface AnimateOptions {@@ -193,11 +195,11 @@ export interface AnimateOptions {}/**- * A closed-form curve a release starts, to play on the compositor through- * `Animator.decay`: a released scroll view's coast and its edge bounce- * (coast.ts). Times are seconds from the curve's start; the value at- * `duration` is the end state. Start it at the property's presentation- * value (`get`) to continue without a jump.+ * Any closed-form curve to play on the compositor (`Animator.play`, and a+ * release's coast through `Animator.decay`): a spring chasing a moving+ * target, a piecewise curve, a fitted UIKit curve. Times are seconds from+ * the curve's start; the value at `duration` is the end state. Start it at+ * the property's presentation value (`get`) to continue without a jump.*/export interface MotionCurve {/** Length, s. */@@ -297,6 +299,19 @@ export interface Animator {transition: SpringTransition,options?: AnimateOptions,): MotionHandle;+ /**+ * Plays given curves (`scale` drives both axes), baked like a spring:+ * presentation values, velocities, `stop`, `finished` and the shared+ * clock work the same, and a later `animate` starts from the curve's+ * value and velocity. Reduced Motion treats a curve that moves x, y, rotate+ * or scale as travel, which the policy replaces (design:reduced-motion: a+ * cross-fade after a touch, an immediate change otherwise). Its handle has+ * no spring of its own: `retarget` needs one.+ */+ play(+ curves: Partial<Record<MotionProperty | 'scale', MotionCurve>>,+ options?: AnimateOptions,+ ): MotionHandle;/*** Plays momentum curves as given, on the translate axes only: a released* scroll view's coast and edge bounce, which `coast()` (coast.ts) builds@@ -305,10 +320,10 @@ export interface Animator {* DR2, DEC-2). A curve marked `isTransition` (coast()'s spring back from* past an edge) is a transition and plays through the Reduce Motion* policy, as `animate` does. Anything else (a fade, a slide a tap starts)- * is a transition too: play it with `animate`. Pass `touchRelease` when a- * touch drag's release starts it, so a spring back cross-fades on any- * pointer (DR2). Only a surface that coasts imports the coast math and the- * scroll table.+ * is a transition too: play it with `play` or `animate`. Pass+ * `touchRelease` when a touch drag's release starts it, so a spring back+ * cross-fades on any pointer (DR2). Only a surface that coasts imports the+ * coast math and the scroll table.*/decay(curves: Partial<Record<'x' | 'y', MotionCurve>>,@@ -722,6 +737,22 @@ export function createAnimator(const restWaits = new Set<RestWait>();/** A detach that settles as an unmount at the end of the task, unless an attach follows. */let unmountQueued = false;+ /**+ * The node the latest attach(null) detached, while its unmount is pending:+ * a waiting Reduce Motion move lands there, so that node is left visible+ * where it was going.+ */+ let lastDetached: HTMLElement | null = null;+ /** Runs `write` with the pending unmount's node as the target. */+ const onLastDetached = (write: () => void) => {+ const current = target;+ target = target ?? lastDetached;+ try {+ write();+ } finally {+ target = current;+ }+ };/** The call being committed, when it starts from rest. */let callGroup: StartGroup | null = null;/** Channels promoted to the element's compositing layer (will-change). */@@ -2150,6 +2181,7 @@ export function createAnimator(// completion timer outlives the element, as in dispose()// (architecture:react-component-runtime INV5). A replacement keeps// them all: the motion goes on on the new node.+ lastDetached = target;if (!unmountQueued) {unmountQueued = true;queueMicrotask(() => {@@ -2157,10 +2189,27 @@ export function createAnimator(return;}unmountQueued = false;- // A Reduce Motion move still waiting lands in the model where it- // was going, as in dispose(), so a later attach shows the element- // there and visible; its calls settle as interrupted.- landPending(false);+ // A Reduce Motion move still waiting lands where it was going, as+ // in dispose(), on the node just detached too: a dip's fade out+ // left its low opacity inline there, so a later attach of that+ // node (a Suspense or Activity reveal) shows it landed and+ // visible. Its calls settle as interrupted.+ onLastDetached(() => {+ landPending(false);+ // The landing's commit rebuilt every channel it touched on the+ // detached node, any axis still moving included: leave that+ // node with no animation, timer or promotion.+ for (const animation of running.values()) {+ animation.cancel();+ }+ running.clear();+ for (const timer of retireTimers.values()) {+ clearTimeout(timer);+ }+ retireTimers.clear();+ demote();+ });+ lastDetached = null;const time = now();for (const property of PROPERTIES) {interrupt(property, time);@@ -2173,6 +2222,7 @@ export function createAnimator(} else {// A node in place of the one just detached: no unmount.unmountQueued = false;+ lastDetached = null;}// After the landing's commit, which can promote the element again.demote();@@ -2345,6 +2395,108 @@ export function createAnimator(return handle;},+ play(curves, playOptions = {}) {+ syncPending();+ const time = playOptions.at ?? now();+ const {owner, finished} = newOwner();+ const byProperty: Partial<Record<MotionProperty, MotionCurve>> = {};+ // `scale` first, so an explicit `scaleX` or `scaleY` beside it wins.+ const entries = (+ Object.entries(curves) as [+ MotionProperty | 'scale',+ MotionCurve | undefined,+ ][]+ ).sort(([a], [b]) => Number(b === 'scale') - Number(a === 'scale'));+ for (const [key, curve] of entries) {+ if (curve == null) {+ continue;+ }+ if (!Number.isFinite(curve.duration) || curve.duration < 0) {+ throw new RangeError(+ `animator: a curve needs a finite duration ≥ 0 (got ${curve.duration})`,+ );+ }+ for (const property of expandList([key])) {+ byProperty[property] = curve;+ }+ }+ const properties = Object.keys(byProperty) as MotionProperty[];+ const targets: Partial<Record<MotionProperty, number>> = {};+ for (const property of properties) {+ const curve = byProperty[property] as MotionCurve;+ targets[property] = curve.at(curve.duration);+ }+ const plan = prefersReducedMotion()+ ? reducedMotion(+ owner,+ time,+ targets,+ properties,+ isCoarsePointer() || playOptions.touchRelease === true,+ playOptions.crossfadeAs,+ )+ : null;+ const next: Partial<Record<MotionProperty, Segment | null>> = {+ ...plan?.next,+ };+ for (const property of properties) {+ if (property in next) {+ continue;+ }+ const curve = byProperty[property] as MotionCurve;+ next[property] =+ curve.duration === 0+ ? null+ : {+ start: time,+ duration: Math.min(MAX_DURATION_MS, curve.duration * 1000),+ target: targets[property] as number,+ at: t => curve.at(t / 1000),+ speed: t => curve.velocity(t / 1000),+ jumps: [],+ owner,+ };+ }+ const group = beginGroup(+ time,+ Object.keys(next) as MotionProperty[],+ playOptions.at,+ );+ const adopted =+ plan?.landing != null+ ? adoptLandings(plan.landing, Object.keys(next) as MotionProperty[])+ : null;+ const changed: MotionProperty[] = [];+ for (const [property, segment] of Object.entries(next) as [+ MotionProperty,+ Segment | null,+ ][]) {+ interrupt(property, time);+ changed.push(property);+ if (segment == null) {+ // Read before the segment goes: valueAt falls back to resting.+ const value =+ plan?.holds[property] ??+ targets[property] ??+ valueAt(property, time);+ segments.delete(property);+ resting[property] = value;+ } else {+ segments.set(property, segment);+ }+ }+ commitCall(group, owner, changed, time);+ if (plan?.borrowed != null) {+ // The dip's own commit cleared it; the borrow lasts the dip.+ borrowedOpacity = plan.borrowed;+ }+ const handle = makeHandle(owner, changed, finished, time, group);+ if (plan?.landing != null) {+ scheduleLanding(owner, handle.started, plan.landing, adopted);+ }+ return handle;+ },+decay(curves, decayOptions = {}) {syncPending();const time = decayOptions.at ?? now();@@ -2591,8 +2743,14 @@ export function createAnimator(dispose() {// A Reduce Motion move still waiting to land is written at its end- // state, so the element is left visible where it was going; its call- // and the calls it carries settle as interrupted.+ // state, so the element is left visible where it was going (the node+ // just detached, when an unmount is pending); its call and the calls+ // it carries settle as interrupted.+ if (target == null && unmountQueued) {+ target = lastDetached;+ }+ lastDetached = null;+ unmountQueued = false;landPending(false);// Nothing moves any more: every atRest() wait settles.for (const wait of [...restWaits]) {