You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 723e045
Browse filesBrowse the repository at this point in the historyBrowse files
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.
[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.
Copy file name to clipboardExpand all lines: apps/storybook/stories/Slider.stories.tsx
+86Lines changed: 86 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -306,3 +306,89 @@ export const PressedState: Story = {
306
306
);
307
307
},
308
308
};
309
+
310
+
exportconstTouchTracking: 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.',
'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.',
Copy file name to clipboardExpand all lines: packages/core/src/Slider/Slider.doc.mjs
+11-7Lines changed: 11 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -237,12 +237,14 @@ export const docs = {
237
237
{
238
238
name: 'containerClassName',
239
239
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`.',
241
242
},
242
243
{
243
244
name: 'containerStyle',
244
245
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`.',
246
248
},
247
249
{
248
250
name: 'controlXstyle',
@@ -295,7 +297,7 @@ export const docs = {
295
297
],
296
298
anatomy,
297
299
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.',
299
301
bestPractices: [
300
302
{
301
303
guidance: true,
@@ -508,7 +510,7 @@ export const docsZh = {
508
510
usage: {
509
511
anatomy,
510
512
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.',
512
514
bestPractices: [
513
515
{
514
516
guidance: true,
@@ -544,7 +546,7 @@ export const docsDense = {
544
546
usage: {
545
547
anatomy,
546
548
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.',
548
550
bestPractices: [
549
551
{
550
552
guidance: true,
@@ -574,10 +576,12 @@ export const docsDense = {
574
576
],
575
577
},
576
578
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.',
578
581
containerClassName: 'Class name for the field container.',
579
582
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.',
581
585
controlClassName: 'Class name for the visual control box.',
582
586
controlStyle: 'Inline styles for the visual control box.',
0 commit comments