Skip to content

Commit 723e045

Browse files
authored
feat(Slider): every pointer drags a thumb by its travel, as UISlider does (#8190)
* feat(Slider): every pointer drags a thumb by its travel, as UISlider does (slider A, end A) A press on a thumb changes no value; once the pointer has moved 10 px the value follows its travel, so the thumb never jumps to the pointer. A finger or a pen claims the drag only along the track, so a swipe across it scrolls the page; a mouse claims in any direction. Under a coarse pointer each thumb takes a finger or a pen through a 48 px target capped at half the gap to a range's other thumb, the held thumb lifts, a release coasts on UISlider's measured spring, and a tap on the track sets the value on lift. A mouse press on the track sets the value where it lands; a secondary click and a wheel or trackpad scroll change nothing. onChangeEnd fires once a finger's or pen's coast settles. UISlider's measured values live in one table. * test(Slider): the scrolling-list test fails if the list never comes to rest It waited up to 4 s for the list's deceleration to finish, then went on whether or not the list had stopped. It now polls until two reads 100 ms apart agree and fails if they never do, so the horizontal drag that follows never runs on a moving list. * docs(motion): the UISlider table cites its measurements without internal capture names The table and its test named the lab's capture and case labels, which mean nothing outside the lab. They now cite the measurement the way the other UIKit tables do: the UIKit lab, the iOS 26.2 simulator, and what was read. * test(Slider): the reach and stillness proofs first check that what they measure is on screen The hit-area proof checks that both thumbs and both touch targets have boxes, and that where the thumbs have room each target is the full 48 px square around its thumb, before measuring the narrowed targets. The list proof checks its thumbs are visible before a swipe that must leave them still, the no-layout proof checks that its drag moved the value, and the desktop-style proof checks the thumb has a box before reading what it lacks. * test(Slider): the busy-main-thread coast proof blocks from the page's own frame The proof waited in the page for the coast, then asked for the block in a second round trip from the test. On a busy machine that trip outlasted the coast's motion and the block landed after the thumb had settled (a judged window of -17 to +8 ms in 10 of 10 runs on two pinned cores). The block now starts from the frame in which the coast passes 48 ms: the page watches the fill, which only a coast animates, from before the release, as blockMainThread asks. * test(Slider): the busy coast proof judges against a compositor control, from a paced flick, to two cast steps from rest The busy-main-thread proof judges the coast against a compositor-only control recorded in the same screencast. Its flick, 900 px/s over 60 ms, keeps the script's spacing in WebKit, whose page reads the release velocity from when the moves arrive, so a stalled dispatch no longer bunches the moves behind it into a far faster throw whose coast reaches the end before the block. It judges until two of the cast's own position steps from rest, so WebKit's 2 px steps read as the cast's resolution, not a stall. The proof and the release filter's stillness reset now run in WebKit too. * test(Slider): a pen lifted while it moves ends its drag at the release, with no coast A finger's release coasts; a pen's, like a mouse's, ends where it lets go (component:Slider FR7). The case lifts a pen at 375 px/s, where a finger would coast, and fails if the release coasts. * test(Slider): the catch plays in the same script as the throw, so a loaded runner cannot let the coast settle first The coast runs on the compositor's clock and reaches its target about 0.4 s after the lift. The test read the value during the throw, then the thumb's box, then played the catching tap on its own, and on a loaded runner those round trips sometimes outlasted the coast: the finger landed on a thumb that had settled at the target (1 of 40 runs at four workers on two cores). The lift value now comes from the script, and a second finger lands 48 ms after the lift, about where the coast has carried the thumb, in the same paced script. * fix(Slider): the review's points, a catch that stops where the thumb is drawn, and a coast that follows the track's live length, on main's harness - The lift and the drop play the `springs.sliderLift` and `springs.sliderDrop` motion roles, which `component:Slider` FR7 now names, as the release coast does with `springs.sliderRelease`. - Each thumb's 48 px touch target is its own `::before`, so a touch presentation renders no more elements than a mouse one, and the recognizers attach to the thumbs for every pointer. - A press on a thumb focuses it for every pointer, as the base did and FR6 relies on for coincident thumbs; a unit case fails on the previous Slider for a finger and a pen. - The two Effects that only mirrored values into refs are gone, and the changeset drops the wheel clause. The end haptic plays only in a finger's or a pen's drag and its coast: a mouse and a track tap play none, as on UISlider (FR7 records iOS Safari's gap). - A finger stops a coast where the browser draws the thumb: the stop reads the thumb's computed translate, not the animator's model of it, which a busy main thread reads past the frame the finger saw. - A coast and a drag follow the track's live length: core's shared ResizeObserver (`observeResize`) watches the track, and a length change re-plays a running coast scaled to the new travel or re-places a drag before the next paint. A value label that takes a digit mid-gesture no longer makes the thumb jump when the parts hand back. - Source comments keep only their reasons; `component:Slider`'s system specs and `spec:AST-094`'s path list carry the links the comments cited. - The proofs run on main's interaction harness. The busy-main-thread proof runs in Chromium; its WebKit form moves to a follow-up on the harness's paced touch play, since WebKit's injected touches bunch behind a stalled dispatch and its JPEG cast moves in 2 px steps. - The catch test sends its finger in its own play once the throw's lift has gone out, so a stalled dispatch cannot bunch the catch behind the lift. It reads the lift's value and the track's length at the lift, as the slider computes its coast from them. - Disabling a slider mid-drag cancels the drag: `onChangeEnd` fires once, with the value the owner rendered, after the Effect's cleanup. An unmount stays silent. - A collapsed track maps no travel, so a drag on it keeps the value. - The docs say what a pen does. - Comments use short sentences, one topic each, and file headers stay short.
1 parent 4479074 commit 723e045

24 files changed

Lines changed: 5937 additions & 250 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] Slider: every pointer drags a thumb by its travel, as UISlider does. A press on a thumb no longer jumps the value to the pointer: once the pointer has moved 10 px, the value follows its further travel along the track. A finger or a pen claims the drag only along the track, so a swipe across the slider scrolls the page; a mouse claims in any direction. On a touch screen each thumb takes a finger or a pen through a 48 px target, capped at half the gap to a range's other thumb, and the held thumb lifts. After a finger's flick the thumb coasts on UISlider's measured spring for about 0.6 s, `onChange` firing through the coast, and `onChangeEnd` reports the value once it settles; a slow drag, a mouse drag and a pen drag end at the release. A tap on the track sets the value when the finger lifts, and a mouse click where it lands; a right click and a macOS ctrl-click change nothing. Under reduced motion the thumb does not lift and a tap's value applies at once.
6+
@vjeux

‎apps/storybook/stories/Slider.stories.tsx‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,89 @@ export const PressedState: Story = {
306306
);
307307
},
308308
};
309+
310+
export const TouchTracking: Story = {
311+
name: 'Touch tracking',
312+
parameters: {
313+
docs: {
314+
description: {
315+
story:
316+
'Under a finger only the thumb takes a drag, through a touch target larger than it; a swipe from the track scrolls the page, and a tap on the track sets the value when the finger lifts. The value follows the finger’s travel past a 10 px start threshold, so the thumb never jumps to the finger, and a release coasts on before `onChangeEnd` reports the value.',
317+
},
318+
},
319+
},
320+
render: args => {
321+
const [value, setValue] = useState(30);
322+
const [range, setRange] = useState<[number, number]>([40, 40]);
323+
const [ends, setEnds] = useState<string[]>([]);
324+
const logEnd = (label: string) => (next: number | [number, number]) =>
325+
setEnds(previous => [
326+
...previous.slice(-4),
327+
`${label} ${Array.isArray(next) ? next.join('–') : next}`,
328+
]);
329+
return (
330+
<div style={{display: 'flex', flexDirection: 'column', gap: 24}}>
331+
<Slider
332+
label="Brightness"
333+
value={value}
334+
onChange={setValue}
335+
onChangeEnd={logEnd('Brightness')}
336+
valueDisplay="text"
337+
max={args.max == null ? undefined : Number(args.max)}
338+
/>
339+
<Slider
340+
label="Hours"
341+
value={range}
342+
onChange={setRange}
343+
onChangeEnd={logEnd('Hours')}
344+
valueDisplay="text"
345+
/>
346+
<output data-testid="slider-change-end" aria-live="polite">
347+
{ends.length === 0 ? 'No change committed yet' : ends.join(', ')}
348+
</output>
349+
</div>
350+
);
351+
},
352+
};
353+
354+
export const InScrollingList: Story = {
355+
name: 'In a scrolling list',
356+
parameters: {
357+
docs: {
358+
description: {
359+
story:
360+
'Sliders in a scrolling list: a vertical swipe that starts on a thumb scrolls the list, a horizontal one drags the thumb, and inside the scroller the thumb lifts only after the content touch delay.',
361+
},
362+
},
363+
},
364+
render: () => {
365+
const [values, setValues] = useState(() =>
366+
Array.from({length: 12}, (_, index) => (index * 37) % 100),
367+
);
368+
return (
369+
<div
370+
data-testid="slider-list"
371+
style={{
372+
height: 360,
373+
overflowY: 'auto',
374+
display: 'flex',
375+
flexDirection: 'column',
376+
gap: 20,
377+
padding: 16,
378+
}}>
379+
{values.map((value, index) => (
380+
<Slider
381+
key={index}
382+
label={`Channel ${index + 1}`}
383+
value={value}
384+
onChange={(next: number) =>
385+
setValues(previous =>
386+
previous.map((current, i) => (i === index ? next : current)),
387+
)
388+
}
389+
/>
390+
))}
391+
</div>
392+
);
393+
},
394+
};

‎docs/specs/AST-094-touch-presentations/motion-roles.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Every motion role a registered table lists (`spec:AST-094` FR4, DEC-5): its kind
1616
| `springs.menuOpen` | spring | response 0.32 s, damping ratio 0.8 | `spec:AST-094` FR4 |
1717
| `springs.quickChange` | spring | duration 0.5 s, bounce 0.15 | `spec:AST-094` FR4 |
1818
| `springs.settle` | spring | duration 0.5 s, bounce 0 | `spec:AST-094` FR4 |
19+
| `springs.sliderDrop` | spring | response 0.5 s, damping ratio 0.7 | `component:Slider` |
20+
| `springs.sliderLift` | spring | response 0.215 s, damping ratio 0.6 | `component:Slider` |
21+
| `springs.sliderRelease` | spring | response 0.4 s, damping ratio 1 | `component:Slider` |
1922
| `springs.stateChange` | spring | response 0.55 s, damping ratio 1 | `spec:AST-094` FR4 |
2023
| `springs.subMenuBack` | spring | response 0.4 s, damping ratio 1 | `spec:AST-094` FR4 |
2124
| `springs.subMenuOpen` | spring | response 0.4 s, damping ratio 0.85 | `spec:AST-094` FR4 |

‎docs/specs/AST-094-touch-presentations/spec.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ affects_consumer_docs: []
2323

2424
# Touch presentations feel native system spec
2525

26+
<!-- path-applicability:v1 -->
27+
28+
```json
29+
{
30+
"paths": ["packages/core/src/motion/uikit/slider.ts"]
31+
}
32+
```
33+
2634
## Intent
2735

2836
A person using an Astryx product on a phone or tablet gets controls, sheets,

‎docs/specs/components/Slider/Slider.spec.md‎

Lines changed: 23 additions & 15 deletions
Large diffs are not rendered by default.

‎internal/eslint-plugin-astryx/no-comment-provenance.baseline.json‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,8 +2221,6 @@
22212221
"DR4",
22222222
"FR34",
22232223
"FR34",
2224-
"FR4",
2225-
"FR4",
22262224
"FR8",
22272225
"INV6",
22282226
"architecture:component-style-authoring",
@@ -2232,8 +2230,6 @@
22322230
"spec quote",
22332231
"spec:AST-094",
22342232
"spec:AST-094",
2235-
"spec:AST-094",
2236-
"spec:AST-094",
22372233
"spec:AST-094"
22382234
],
22392235
"packages/core/src/motion/uikit/timing.ts": [

‎packages/cli/test/__golden__/no-icon-set/search-icon-set.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "search",
44
"data": {
55
"query": "icon set",
6-
"matchCount": 373,
6+
"matchCount": 374,
77
"results": [
88
{
99
"domain": "doc",

‎packages/cli/test/__golden__/no-icon-set/search-icon-set.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Results for "icon set" (20 of 373)
1+
Results for "icon set" (20 of 374)
22
name: authoring/building-blocks/templates/build-the-template/template-assets/template-icons
33
section: use-astryx-icon
44
domain: doc

‎packages/core/src/Slider/Slider.doc.mjs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,14 @@ export const docs = {
237237
{
238238
name: 'containerClassName',
239239
type: 'string',
240-
description: 'Class name for the field container. Same targeting as `containerXstyle`.',
240+
description:
241+
'Class name for the field container. Same targeting as `containerXstyle`.',
241242
},
242243
{
243244
name: 'containerStyle',
244245
type: 'CSSProperties',
245-
description: 'Inline styles for the field container. Same targeting as `containerXstyle`.',
246+
description:
247+
'Inline styles for the field container. Same targeting as `containerXstyle`.',
246248
},
247249
{
248250
name: 'controlXstyle',
@@ -295,7 +297,7 @@ export const docs = {
295297
],
296298
anatomy,
297299
description:
298-
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage.',
300+
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage. Under a finger, on any touch device, it tracks as UISlider does: only the thumb takes a drag, through a target larger than it, the value follows the finger’s travel rather than jumping to it, a release coasts on before `onChangeEnd`, a swipe from the track scrolls the page, and a tap on the track or a mark sets the value when the finger lifts (the thumb springs there). A mouse drag on a thumb tracks the same way, past the same 10 px in any direction, with no lift or coast; a mouse press on the track moves the thumb there, and only a primary click presses. A pen drags as a finger does, claiming only along the track, and its drag ends at the release with no coast. A wheel or a trackpad scroll over the slider goes to whatever scrolls under it.',
299301
bestPractices: [
300302
{
301303
guidance: true,
@@ -508,7 +510,7 @@ export const docsZh = {
508510
usage: {
509511
anatomy,
510512
description:
511-
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage.',
513+
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage. Under a finger, on any touch device, it tracks as UISlider does: only the thumb takes a drag, through a target larger than it, the value follows the finger’s travel rather than jumping to it, a release coasts on before `onChangeEnd`, a swipe from the track scrolls the page, and a tap on the track or a mark sets the value when the finger lifts (the thumb springs there). A mouse drag on a thumb tracks the same way, past the same 10 px in any direction, with no lift or coast; a mouse press on the track moves the thumb there, and only a primary click presses. A pen drags as a finger does, claiming only along the track, and its drag ends at the release with no coast. A wheel or a trackpad scroll over the slider goes to whatever scrolls under it.',
512514
bestPractices: [
513515
{
514516
guidance: true,
@@ -544,7 +546,7 @@ export const docsDense = {
544546
usage: {
545547
anatomy,
546548
description:
547-
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage.',
549+
'A draggable control for selecting a numeric value or range within defined bounds. Supports single value and range selection, tick marks, custom value formatting, and vertical orientation. Use it when users need to explore a continuous range, such as volume, price, or percentage. Under a finger, on any touch device, it tracks as UISlider does: only the thumb takes a drag, through a target larger than it, the value follows the finger’s travel rather than jumping to it, a release coasts on before `onChangeEnd`, a swipe from the track scrolls the page, and a tap on the track or a mark sets the value when the finger lifts (the thumb springs there). A mouse drag on a thumb tracks the same way, past the same 10 px in any direction, with no lift or coast; a mouse press on the track moves the thumb there, and only a primary click presses. A pen drags as a finger does, claiming only along the track, and its drag ends at the release with no coast. A wheel or a trackpad scroll over the slider goes to whatever scrolls under it.',
548550
bestPractices: [
549551
{
550552
guidance: true,
@@ -574,10 +576,12 @@ export const docsDense = {
574576
],
575577
},
576578
propDescriptions: {
577-
containerXstyle: 'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',
579+
containerXstyle:
580+
'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',
578581
containerClassName: 'Class name for the field container.',
579582
containerStyle: 'Inline styles for the field container.',
580-
controlXstyle: 'StyleX styles for the visual control box (border, background, icons); not the native input.',
583+
controlXstyle:
584+
'StyleX styles for the visual control box (border, background, icons); not the native input.',
581585
controlClassName: 'Class name for the visual control box.',
582586
controlStyle: 'Inline styles for the visual control box.',
583587
label: 'Label text (always rendered for a11y).',

0 commit comments

Comments
 (0)