An open source design system that's fully customizable and agent ready
TypeScript
test(PageControl): the slide's own keyframes approach without overshoot (#10601)
Christopher Chedeaud7326d9e77dd
diff --git a/packages/lab/src/PageControl/PageControlTouch.ts b/packages/lab/src/PageControl/PageControlTouch.tsindex 1fd4007e00..383667b527 100644--- a/packages/lab/src/PageControl/PageControlTouch.ts+++ b/packages/lab/src/PageControl/PageControlTouch.ts@@ -437,7 +437,7 @@ export function usePageControlTouch({switch (hold.state) {case 'began':begin(landingX(hold, x));- // The held look commits in the hold timer's own task. A render+ // The held look commits in the task where the hold begins. A render// scheduled after it can wait behind a busy page's other tasks.flushSync(showHeld);break;diff --git a/packages/lab/src/PageControl/__tests__/PageControl.interaction.browser.spec.ts b/packages/lab/src/PageControl/__tests__/PageControl.interaction.browser.spec.tsindex 7e369f89da..7c9f2eb49c 100644--- a/packages/lab/src/PageControl/__tests__/PageControl.interaction.browser.spec.ts+++ b/packages/lab/src/PageControl/__tests__/PageControl.interaction.browser.spec.ts@@ -1053,6 +1053,19 @@ test('a windowed control slides one slot 50 ms after the change, on a critically});}expect(startedAt - changedAt).toBeLessThan(120);+ // A critically damped spring reaches the next slot without passing it. The+ // slide's own keyframes show that, and a loaded runner cannot change them.+ const keyXs = curve.xs.map(([, x]) => x);+ for (let i = 1; i < keyXs.length; i++) {+ expect(+ keyXs[i],+ "the slide's keyframes never turn back",+ ).toBeLessThanOrEqual(keyXs[i - 1] + 0.01);+ }+ expect(+ Math.min(...keyXs),+ "the slide's keyframes never pass the next slot",+ ).toBeGreaterThanOrEqual(-19 * PITCH - 0.01);// Monotonic to the next slot, settled within ~0.35 s of starting.const xs = trace.filter(s => s.t >= startedAt).map(s => s.x);for (let i = 1; i < xs.length; i++) {