Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(RefreshControl): the end plays UIKit's curve over the duration token (#10582)

Christopher Chedeau3b8eb80d1382
diff --git a/docs/specs/AST-094-touch-presentations/spec.md b/docs/specs/AST-094-touch-presentations/spec.md
index 3eb3839533..6905c8e9c3 100644
--- a/docs/specs/AST-094-touch-presentations/spec.md
+++ b/docs/specs/AST-094-touch-presentations/spec.md
@@ -999,6 +999,11 @@ under a finger, and a mouse follows `module:DropdownMenu/useMenuPress` FR3 and
- Under FR45, a swipe row is a gesture component: a close or return that a tap
or Escape starts (`spec:AST-057` FR5, FR7) plays the row's spring from rest,
and a swipe that closes it keeps its measured spring from the release.
+- Under FR45, RefreshControl's endRefreshing is the exception: it plays UIKit's
+ measured 300 ms ease-in-out curve from the theme's duration token and UIKit's
+ measured curve, since no spring from rest matches it within tolerance (iOS
+ 26.2 simulator, 2026-11-07). The curve follows the theme's tempo through the
+ duration token, so a slower theme still slows it.
- Under FR45, `spec:AST-107`'s `settleTo` and an `animate` call without a
velocity play a spring for motion that no gesture drives. Their records keep
their springs until each carries FR45.
@@ -1062,6 +1067,7 @@ Motion that FR45 moves, by component. Each component's record carries its own li
| FR45 | Browser tests with a mouse, a pen, a trackpad and a finger at each `tempo` bound and each `character`, and with Reduce Motion | a tap, a click, a key and a programmatic change on a Switch, a menu, an alert, a sheet and a ProgressBar under a fine and a coarse pointer; a drag release, a flick and a pinch on a Switch, a Slider, a sheet, a pager and a Lightbox photo under each pointer; a tap that continues as a drag | a tap, click, key or programmatic change in a tap-classified component that plays a measured role or a spring instead of the theme's duration and easing tokens, a touch tap-started move in a gesture or gesture-capable component on a curve instead of its spring, a click, a key or a value change on Switch or SegmentedControl without a touch presentation that leaves the theme's curve, a velocity-carrying release that settles from rest or on a curve, a gesture's spring that ignores `character` or `tempo`, or a part that follows one pointer and not another, fails; the pager's measured settle, which does not yet follow `character`, is a recorded implementation gap |
| FR45 | Component source and token tests for a tap component's motion whose record names no step, with a platform measurement | a small anchored surface (a popover, a menu, a toggle, a row) and a full-screen surface (a Dialog, an AlertDialog), each with its own measurement; a tap component's overlay exit | a token cited as nearest to the measurement in the Storybook theme passes, and a tap component's overlay exit on `--duration-exit` passes; a token chosen by role alone, or nearest at Core's unthemed defaults, fails |
| FR45 | Browser frame capture of companion motion in a gesture and a tap component | a sheet's scrim, handle and content fade; a Lightbox's chrome fade; a menu's backdrop | a companion fade on its own duration fails; one driven by the main motion's progress or settle time passes |
+| FR45 | Browser frame trace of RefreshControl's end at `tempo` 1 and at each `tempo` bound, and a unit test of the end's timing | a refresh that ends with its indicator shown, at `tempo` 1 (300 ms), 0.75 (225 ms) and 1.5 (450 ms); a theme whose move easing differs from UIKit's curve | an end whose per-frame trace leaves UIKit's measured 300 ms ease-in-out by more than 0.75 pt at `tempo` 1, an end on the theme's move easing instead of UIKit's curve, or a duration that ignores the theme's `tempo`, fails |
| FR9, FR10 | Recognizer unit tests on synthetic streams and browser tests with real touch input | drag, second finger, pinch, page zoom, main-thread block | a second finger that breaks a drag, or a page pinch blocked other than by the author's `touch-action`, fails |
| FR11, FR12 | Press and long-press tests on synthetic streams with explicit timestamps | inside and outside a scroll view; a drag the browser takes; a lift inside; a menu row under a finger; a press on a row of a menu whose rows fit and of one that scrolls; a slide-off lift on a Switch and on a Radio | the wrong profile's timing, a press that survives the browser taking the touch, or a control outside an action group activated other than by the browser's click, outside `spec:AST-020` FR9's slide-off exception, a row of a menu whose rows fit that waits 150 ms, or one of a scrolling menu that does not, or a slide-off lift that completes a control outside `spec:AST-020` FR9's exception, fails |
| FR11 theme | `generateThemeRules.test.ts` themed-`:active` cases; real-browser forced `:active` on the Themed press story | a theme `:active` on a base and on a variant with a trailing pseudo; fine pointer; coarse pointer with forced `:active` and with the press attribute | a bare theme `:active` rule a coarse pointer matches, or a coarse arm keyed on `:active`, fails |
diff --git a/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts b/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
index 507149cb8d..84c6343b12 100644
--- a/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
+++ b/packages/lab/src/RefreshControl/__tests__/RefreshControl.interaction.browser.spec.ts
@@ -28,8 +28,9 @@
// test. The pan's hysteresis is 10 px, and 60 px follow one to one. Then
// UIScrollView's rubber band applies to the excess (c = 0.55, d = the
// scroller's height). The trigger is at max(73, 0.198 × d) px of overscroll.
-// The settle uses response 0.5 s and damping 1. UIKit's end takes 300 ms,
-// and the page's own tokens give the end's duration and easing.
+// The settle uses response 0.5 s and damping 1. UIKit's end takes 300 ms on
+// UIView.animate's easeInEaseOut. The page's duration token gives the end's
+// duration, and the curve stays UIKit's whatever the theme's easing.
import {
expect,
@@ -75,6 +76,9 @@ const storybook = withStorybook(test);
/** UIKit's end, measured: `endRefreshing()` moves the content over 0.3 s. */
const UIKIT_END_MS = 300;
+/** UIKit's end curve: UIView.animate's default, easeInEaseOut. */
+const UIKIT_END_CURVE = [0.42, 0, 0.58, 1] as const;
+
/** A CSS time in ms, for the page's duration tokens. */
function timeMs(value: string): number {
const match = /^\s*(\d*\.?\d+)(ms|s)\s*$/.exec(value);
@@ -84,16 +88,6 @@ function timeMs(value: string): number {
return Number(match[1]) * (match[2] === 's' ? 1000 : 1);
}
-/** The control points of a CSS cubic-bezier easing, for the page's tokens. */
-function bezierPoints(value: string): [number, number, number, number] {
- const match = /^\s*cubic-bezier\(([^)]*)\)\s*$/.exec(value);
- const points = match?.[1].split(',').map(Number) ?? [];
- if (points.length !== 4 || points.some(n => !Number.isFinite(n))) {
- throw new Error(`bezierPoints: not a cubic-bezier: "${value}"`);
- }
- return points as [number, number, number, number];
-}
-
/** The theme tokens at the content, as the page computes them. */
const tokensAt = (content: Locator, names: readonly string[]) =>
content.evaluate(
@@ -431,14 +425,16 @@ test('the settle onto the inset follows the scroll view’s bounce spring', asyn
expect(samples.at(-1)?.value).toBeCloseTo(HEIGHT, 0);
});
-test('the end slides the content up on the theme’s duration and move easing tokens (spec:AST-094 FR45)', async ({
+test('the end slides the content up on UIKit’s curve over the theme’s duration token (spec:AST-094 FR45)', async ({
page,
}, testInfo) => {
const {driver, content, start} = await openRefresh(page, undefined, {
refreshMs: '-1',
});
- const tokens = await tokensAt(content, ['--duration-medium', '--ease-move']);
+ const tokens = await tokensAt(content, ['--duration-medium']);
const ms = timeMs(tokens['--duration-medium']);
+ // The Storybook theme is neutral: its medium duration is UIKit's end.
+ expect(ms, JSON.stringify(tokens)).toBe(UIKIT_END_MS);
await driver.play(slowPull(start, 300, 200));
await waitForContentRest(content);
expect(await shownPull(content)).toBeCloseTo(HEIGHT, 0);
@@ -446,7 +442,7 @@ test('the end slides the content up on the theme’s duration and move easing to
await waitForSettle(content, {afterRefresh: true, hold: true});
const samples = await sampleTranslate(content, timeline(ms));
await releaseAnimations(page);
- const ease = cubicBezier(...bezierPoints(tokens['--ease-move']));
+ const ease = cubicBezier(...UIKIT_END_CURVE);
const oracle = (t: number) => HEIGHT * (1 - ease(Math.min(1, t / ms)));
const result = compareCurve(samples, oracle, 0.75);
await writeEvidence(
@@ -1031,6 +1027,56 @@ test('a theme’s duration token retimes the end, and a `--motion-…` variable
expect(Math.abs((slide?.movingMs ?? 0) - 600)).toBeLessThan(20);
});
+for (const tempo of [0.75, 1.5]) {
+ test(`at a theme tempo of ${tempo}, the end plays UIKit’s curve over the duration token that tempo writes (spec:AST-094 FR45, spec:AST-108)`, async ({
+ page,
+ }, testInfo) => {
+ // A theme with a tempo writes each duration token as its value times
+ // the tempo, to the ms, and writes the tempo beside it. So the neutral
+ // 300 ms is 225 ms at the quickest bound and 450 ms at the slowest.
+ const ms = Math.round(UIKIT_END_MS * tempo);
+ const {driver, content, start} = await openRefresh(page, undefined, {
+ refreshMs: '-1',
+ });
+ await content.evaluate(
+ (element, values) => {
+ element.style.setProperty('--duration-medium', `${values.ms}ms`);
+ element.style.setProperty(
+ '--_astryx-motion-tempo',
+ String(values.tempo),
+ );
+ },
+ {ms, tempo},
+ );
+ await driver.play(slowPull(start, 300, 200));
+ await waitForContentRest(content);
+ expect(await shownPull(content)).toBeCloseTo(HEIGHT, 0);
+ await endRefresh(page);
+ await waitForSettle(content, {afterRefresh: true, hold: true});
+ const samples = await sampleTranslate(content, timeline(ms));
+ await releaseAnimations(page);
+ const ease = cubicBezier(...UIKIT_END_CURVE);
+ const oracle = (t: number) => HEIGHT * (1 - ease(Math.min(1, t / ms)));
+ const result = compareCurve(samples, oracle, 0.75);
+ await writeEvidence(
+ `curves/refresh-end-tempo-${tempo}`,
+ {
+ [`${testInfo.project.name}.json`]: JSON.stringify(
+ {ms, samples, result},
+ null,
+ 1,
+ ),
+ },
+ testInfo,
+ );
+ expect(result.maxError, JSON.stringify(result.worst)).toBeLessThanOrEqual(
+ 0.75,
+ );
+ await waitForContentRest(content);
+ expect(await shownPull(content)).toBeCloseTo(0, 1);
+ });
+}
+
/** A desktop context: no touch screen, so CSS and script read a fine pointer. */
async function desktopPage(
browser: Browser,
diff --git a/packages/lab/src/RefreshControl/refreshPull.test.ts b/packages/lab/src/RefreshControl/refreshPull.test.ts
index d1a1d60b9a..b627710023 100644
--- a/packages/lab/src/RefreshControl/refreshPull.test.ts
+++ b/packages/lab/src/RefreshControl/refreshPull.test.ts
@@ -219,11 +219,12 @@ describe('release and end', () => {
});
});
-describe('the end’s timing from the theme’s tokens', () => {
- it('plays the theme’s duration and move easing tokens as the element computes them (spec:AST-094 FR45)', () => {
+describe('the end’s timing', () => {
+ it('plays UIKit’s easeInEaseOut over the theme’s duration token as the element computes it (spec:AST-094 FR45)', () => {
const style = (values: Record<string, string>) => ({
getPropertyValue: (name: string) => values[name] ?? '',
});
+ // The theme's move easing changes nothing: the curve is UIKit's.
expect(
endTiming(
style({
@@ -231,17 +232,12 @@ describe('the end’s timing from the theme’s tokens', () => {
'--ease-move': 'cubic-bezier(0.24, 1, 0.4, 1)',
}),
),
- ).toEqual({ms: 300, points: [0.24, 1, 0.4, 1]});
+ ).toEqual({ms: 300, points: [0.42, 0, 0.58, 1]});
// A theme's tempo reaches the end through the token's value.
+ expect(endTiming(style({'--duration-medium': '450ms'}))?.ms).toBe(450);
+ // No token, or a token in a form it cannot read: no slide.
expect(
- endTiming(style({'--duration-medium': '450ms', '--ease-move': 'ease'}))
- ?.ms,
- ).toBe(450);
- // No tokens, or tokens in a form it cannot read: no slide.
- expect(
- endTiming(
- style({'--duration-medium': 'calc(300ms * 1)', '--ease-move': 'ease'}),
- ),
+ endTiming(style({'--duration-medium': 'calc(300ms * 1)'})),
).toBeNull();
expect(endTiming(style({}))).toBeNull();
});
diff --git a/packages/lab/src/RefreshControl/refreshPull.ts b/packages/lab/src/RefreshControl/refreshPull.ts
index c8d935ffa6..12d7df5d69 100644
--- a/packages/lab/src/RefreshControl/refreshPull.ts
+++ b/packages/lab/src/RefreshControl/refreshPull.ts
@@ -3,11 +3,11 @@
/**
* @file refreshPull.ts
* @input The pull values (refreshValues.ts), and the rubber band, the cubic
- * Bézier and the motion-role parsers (Core's internal touch entry)
+ * Bézier and the duration parser (Core's internal touch entry)
* @output Exports the pull mapping (finger travel → overscroll), its slope
* and its inverse, and the trigger distance. It also exports the reveal, a
- * refresh's release and end targets, and the end's timing from the theme's
- * tokens.
+ * refresh's release and end targets, and the end's timing: the theme's
+ * duration token and UIKit's curve.
* @position Pure math for useRefreshControl; no DOM, no React
*
* SYNC: When modified, update:
@@ -27,10 +27,7 @@ import {
rubberBandInverse,
rubberBandSlope,
} from '@astryxdesign/core/internal/touch';
-import {
- parseCssEasing,
- parseMotionRoleValue,
-} from '@astryxdesign/core/internal/touch';
+import {parseMotionRoleValue} from '@astryxdesign/core/internal/touch';
import {refreshControl} from './refreshValues';
/** The refreshing inset and one-to-one stretch, pt. */
@@ -168,9 +165,10 @@ export function endMotion(scrolled: number): {
}
/**
- * The end's duration and curve: the theme tokens that `refreshControl` names,
- * as the end's element computes them. Null when either token is missing or
- * in a form it cannot read, such as `calc()`, `var()` or `steps()`.
+ * The end's duration and curve. The duration is the theme token that
+ * `refreshControl` names, as the end's element computes it. The curve is
+ * UIView.animate's easeInEaseOut, whatever the theme's easing. Null when the
+ * token is missing or in a form it cannot read, such as `calc()` or `var()`.
*/
export function endTiming(
style: Pick<CSSStyleDeclaration, 'getPropertyValue'>,
@@ -179,8 +177,5 @@ export function endTiming(
'duration',
style.getPropertyValue(refreshControl.endDurationToken),
);
- const points = parseCssEasing(
- style.getPropertyValue(refreshControl.endEasingToken),
- );
- return ms == null || points == null ? null : {ms, points};
+ return ms == null ? null : {ms, points: refreshControl.revealCurve};
}
diff --git a/packages/lab/src/RefreshControl/refreshTouchController.ts b/packages/lab/src/RefreshControl/refreshTouchController.ts
index e4f66cb91e..525e2e7c3a 100644
--- a/packages/lab/src/RefreshControl/refreshTouchController.ts
+++ b/packages/lab/src/RefreshControl/refreshTouchController.ts
@@ -34,9 +34,9 @@
// scroll view and writes how much of it the pull reveals. It fades it as a
// settle takes the content back.
//
-// The settle hands the table's spring to the animator. The end plays the
-// theme's duration and move easing tokens, read at its start, so the theme's
-// tempo scales it. Finger tracking runs on the main thread, because the
+// The settle hands the table's spring to the animator. The end plays
+// UIKit's curve over the theme's duration token, read at its start, so the
+// theme's tempo scales it. Finger tracking runs on the main thread, because the
// browser has no refresh pull to ride. Every release, settle and end runs on
// the compositor.
@@ -556,8 +556,9 @@ export function useRefreshTouchController({
resetIndicator();
}
};
- // The theme's tokens as they apply here, at the end's start. With no
- // tokens, or tokens in a form it cannot read, the end has no slide.
+ // The theme's duration token as it applies here, at the end's start.
+ // With no token, or a token in a form it cannot read, the end has no
+ // slide.
const timing =
element == null ? null : endTiming(getComputedStyle(element));
if (timing == null || timing.ms <= 0) {
diff --git a/packages/lab/src/RefreshControl/refreshValues.ts b/packages/lab/src/RefreshControl/refreshValues.ts
index e431e63612..3f63d4c440 100644
--- a/packages/lab/src/RefreshControl/refreshValues.ts
+++ b/packages/lab/src/RefreshControl/refreshValues.ts
@@ -5,7 +5,7 @@
* @input Nothing; data only
* @output Exports `refreshControl`, UIRefreshControl's pull values: the
* refreshing inset, the trigger, the pull after it, the reveal, the end, and
- * the theme tokens the end plays
+ * the end's duration token
* @position Internal to the refresh pull. A release onto the inset uses Core's
* `scroll.bounce`, and a pull past `height` uses Core's rubber band.
*/
@@ -61,13 +61,16 @@ export const refreshControl = {
revealCurve: [0.42, 0, 0.58, 1],
/**
* `endRefreshing()` while the control is visible: the inset leaves (the
- * content moves up by `height`) over this long. The end plays the theme
- * duration token nearest it (`endDurationToken`). This value stays as the
+ * content moves up by `height`) over this long. UIView.animate plays it on
+ * its default curve, easeInEaseOut, which has the control points of
+ * `revealCurve`. The end plays that curve over the theme duration token
+ * nearest this value (`endDurationToken`). This value stays as the
* reference for that choice.
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
* iPhone 17 Pro, setContentOffset per frame over 0.3 s inside
* UIView.animate(withDuration: 0.3), three runs at rest identical to the
* frame, Oct 23 2026
+ * @source apple-docs https://developer.apple.com/documentation/quartzcore/camediatimingfunctionname/easeineaseout
*/
endMs: 300,
/**
@@ -75,6 +78,4 @@ export const refreshControl = {
* value is the one nearest `endMs`: 300 ms. The theme's tempo scales it.
*/
endDurationToken: '--duration-medium',
- /** The easing token that the end plays: the content moves. */
- endEasingToken: '--ease-move',
} as const;