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 3d225c3
Browse filesBrowse the repository at this point in the historyBrowse files
feat(core): under a finger a pressable highlights at touch-down outside scroll views (#9765)
feat(core): under a finger a pressable highlights at touch-down outside scroll views
A touch on a pressable that is not inside a scroll view paints its press
in the frame the finger lands, as a UIControl does; inside a scroll view
the content-touch delay still applies. The press controller and the
gesture core's scroll probe share one scroll-view test (utils/scrollView).
The WebKit interaction proofs now run when that module changes.
Co-authored-by: Cindy Zhang <cindyxz@meta.com>
Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
[fix] Under a finger, a pressable (a button, card, link, list row or any other surface) outside a scroll view now highlights in the frame the finger lands, as UIKit's controls do, instead of after a 150 ms delay. Inside a scroll view it still waits that delay, so a flick paints nothing, and a scroll that takes a held press cancels it with no fade. A page that scrolls counts as a scroll view, so on a page taller than the screen a press still waits; a control in a fixed bar, or on a page that fits, highlights at once. A mouse on a desktop keeps `:active`.
Copy file name to clipboardExpand all lines: apps/storybook/stories/PressFeedback.stories.tsx
+39-13Lines changed: 39 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,11 @@ import {VStack} from '@astryxdesign/core/Layout';
26
26
* View these with a coarse pointer: in Chromium, open DevTools, toggle the
27
27
* device toolbar (a phone preset), and use the touch cursor; or open Storybook
28
28
* on a phone. Under a finger the bare `:active` arm is dropped and the press
29
-
* follows the clocks a native list uses: nothing paints for 150 ms; a held
30
-
* press then paints the full pressed overlay on the next frame; travelling
31
-
* 10 px, or a scroll claiming the gesture, cancels it with no fade and nothing
32
-
* repaints until a new touch; a tap shorter than the delay paints at the lift;
33
-
* the release fades over 200 ms. A mouse keeps `:active`.
29
+
* follows UIKit. A surface highlights in the frame the finger lands, or
30
+
* 150 ms later inside a scroller, where a flick paints nothing; travelling
31
+
* 10 px, or the browser taking the touch to scroll, cancels it with no fade;
32
+
* a tap shorter than the delay paints at the lift; the lift fades it out. A
33
+
* mouse keeps `:active` on a desktop.
34
34
*/
35
35
constmeta: Meta={
36
36
title: 'Core/Press feedback (touch)',
@@ -39,7 +39,7 @@ const meta: Meta = {
39
39
docs: {
40
40
description: {
41
41
component:
42
-
'The touch press model on every pressable surface. View with a coarse pointer (DevTools device toolbar, or a phone). Under a finger the bare `:active` arm is dropped and one document-level controller writes `data-astryx-press="on"` once a press is believed (150 ms, no travel, no scroll) and `data-astryx-press="fading"` for the 200 ms release; a scroll or 10 px of travel cancels with no fade, and nothing repaints until a new touch. A mouse keeps `:active`. Scroll the list stories with a finger: no row paints while the list moves.',
42
+
'The touch press model on every pressable surface. View with a coarse pointer (DevTools device toolbar, or a phone). Under a finger the bare `:active` arm is dropped and one document-level controller writes `data-astryx-press="on"` while a press is held and `data-astryx-press="fading"` for the release. A surface highlights in the frame the finger lands (150 ms later inside a scroller) and fades at the lift; 10 px of travel or a scroll claiming the touch cancels it with no fade. A mouse keeps `:active` on a desktop. Scroll the list stories with a finger: nothing paints while the list moves.',
43
43
},
44
44
},
45
45
},
@@ -48,12 +48,12 @@ const meta: Meta = {
48
48
exportdefaultmeta;
49
49
typeStory=StoryObj;
50
50
51
-
consttouchNote=(what: string)=>
52
-
`${what}Hold: paints after 150 ms. Tap: paints at the lift. Drag or scroll: never paints, and stays dark until the finger lifts and lands again.`;
51
+
constcontrolNote=(what: string)=>
52
+
`${what}Touch: paints in the frame the finger lands. Lift: fades out. A scroll that takes the touch: the paint goes at once, with no fade and no click.`;
53
53
54
54
exportconstButtons: Story={
55
55
parameters: {
56
-
docs: {description: {story: touchNote('Buttons under a finger.')}},
56
+
docs: {description: {story: controlNote('Buttons under a finger.')}},
57
57
},
58
58
render: ()=>(
59
59
<VStackgap={3}>
@@ -70,9 +70,8 @@ export const Rows: Story = {
70
70
parameters: {
71
71
docs: {
72
72
description: {
73
-
story: touchNote(
74
-
'Item rows, a menu, and a clickable card. The list scrolls: flick it and no row paints; stop it with a finger and that touch is a brake, not a press.',
75
-
),
73
+
story:
74
+
'Item rows, a menu, and a clickable card. The rows sit in a scroller, so a held row paints after 150 ms, a tap paints at the lift, and a drag or scroll never paints; the card, outside it, paints in the frame the finger lands. Flick the list and no row paints.',
76
75
},
77
76
},
78
77
},
@@ -113,7 +112,7 @@ export const Controls: Story = {
113
112
parameters: {
114
113
docs: {
115
114
description: {
116
-
story: touchNote(
115
+
story: controlNote(
117
116
'The eight components that gained a pressed state, under a finger.',
118
117
),
119
118
},
@@ -159,3 +158,30 @@ export const Controls: Story = {
159
158
);
160
159
},
161
160
};
161
+
162
+
exportconstButtonsInScroller: Story={
163
+
parameters: {
164
+
docs: {
165
+
description: {
166
+
story:
167
+
'Buttons in a scrolling list, under a finger: a held button paints 150 ms after the finger lands (UIScrollView.delaysContentTouches); a flick scrolls the list and paints nothing; a scroll that starts after the button painted takes the touch, and the paint goes at once with no fade and no click.',
0 commit comments