Skip to content

Commit c19ca12

Browse files
authored
chore(gestures): press tracking ships only its press clocks, and the README documents kind and createPressTracker (#9745)
chore(gestures): press tracking ships only its press clocks, and the README documents kind and createPressTracker Press tracking read its release clock through the whole UIKit timing table, so Switch, Slider, SegmentedControl and DateTimeInput, the controls built on press tracking, shipped the whole table. It now imports the table's press clocks alone. A bundle test pins it: the press tracker's bundle carries the release clock and none of the rows only the whole table has. Nothing changes in how a press behaves. The gestures README now documents two things the code already does: each recognizer reports what it is in `kind`, which code reads in place of `instanceof`, and `createPressTracker` builds press tracking.
1 parent f88f5dc commit c19ca12

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[chore] Internal: press tracking imports only the UIKit timing table's press clocks, so Switch, Slider, SegmentedControl and DateTimeInput, the controls built on press tracking, no longer ship the whole table. Nothing changes in how a press behaves.
6+
7+
@vjeux

‎packages/core/src/gestures/PressTracker.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
*/
4848

4949
import {UIKIT_CONTROL, UIKIT_PAN, UIKIT_PRESS} from '../motion/uikit/gestures';
50-
import {timing} from '../motion/uikit/timing';
50+
// Importing the whole table bundles its curves into each press-tracking control.
51+
import {press as pressClocks} from '../motion/uikit/timing';
5152
import {travel} from './geometry';
5253
import type {GestureRecognizer, SelectionLock} from './GestureRecognizer';
5354
import type {TapGestureRecognizer} from './TapGestureRecognizer';
@@ -154,7 +155,7 @@ export const PRESS_PROFILES = {
154155
// The shared press styles release every surface on the deselect clock
155156
// until a control runs its own release (UIButton's 250 ms), so a
156157
// painter's `fading` never outlasts the fade it shows.
157-
releaseMs: timing.press.highlightOutMs,
158+
releaseMs: pressClocks.highlightOutMs,
158159
},
159160
/**
160161
* A table or collection cell: inside a scroll view it highlights after the
@@ -165,7 +166,7 @@ export const PRESS_PROFILES = {
165166
highlightDelay: 'inScrollers',
166167
cancelTravel: UIKIT_PAN.hysteresis.value,
167168
quickTapFlash: 0,
168-
releaseMs: timing.press.highlightOutMs,
169+
releaseMs: pressClocks.highlightOutMs,
169170
},
170171
} as const satisfies Record<string, PressProfile>;
171172

‎packages/core/src/gestures/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ Once a drag has claimed its finger, a second finger never breaks it.
9696
| `PinchGestureRecognizer` | `UIPinchGestureRecognizer` | continuous | `scale` (settable, to re-base it), `velocity` in scale per second, `focalPoint()` |
9797
| `ScreenEdgePanGestureRecognizer` | `UIScreenEdgePanGestureRecognizer` | continuous | `edges`: `leading` / `trailing`, resolved against the view's writing direction; attached to an edge zone the view lies within; fails as soon as the touch lands outside every requested edge band; a finger's only |
9898

99+
Each recognizer reports what it is in `kind` (`'tap'`, `'longPress'`,
100+
`'pan'`, `'screenEdgePan'`, `'swipe'`, `'pinch'`): code tells the family apart by it, never by `instanceof`
101+
(`architecture:react-component-runtime` INV13).
102+
99103
A recognizer created with `claimsTouches: false` is a watcher (a tab bar
100104
that minimizes while the page scrolls): it never claims, so its element gets
101105
only passive listeners and a scroll never waits for it; it prevents no other
@@ -174,7 +178,9 @@ innerPan.requireToFail(edgePan);
174178
## Touches in the view: `createPressTracker`
175179

176180
A pressable control's view-level touch handling, with `UIControl`
177-
semantics:
181+
semantics, built by `createPressTracker(options)`: a factory, as
182+
`architecture:react-component-runtime` INV13 asks of the touch modules outside
183+
the recognizer family (`VelocityTracker` is still a class, its one listed gap):
178184

179185
- `touchDown`, `touchDragInside` / `touchDragOutside`, `touchDragEnter` /
180186
`touchDragExit`, `touchUpInside` / `touchUpOutside`, `touchCancel`.

‎packages/core/src/gestures/__tests__/GestureHost.bundle.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* @input GestureHost.ts, PressTracker.ts and usePressTracker.ts, bundled and
66
* minified by esbuild
77
* @output The gesture host, the press tracker and its hook carry only the
8-
* UIKit gesture groups they read, never the whole table
8+
* UIKit gesture groups they read, never the whole table. The press tracker
9+
* carries only the timing table's press clocks
910
* (architecture:component-style-authoring INV6)
1011
* @position Bundle evidence for packages/core/src/gestures: every recognizer
1112
* and press tracker attaches through the host, so what it imports ships
@@ -102,4 +103,11 @@ describe.each([
102103
expect(text).not.toContain(key);
103104
}
104105
});
106+
it('carries only the press clocks of the UIKit timing table, never the whole table', () => {
107+
expect(text).toContain('highlightOutMs:');
108+
// Rows only the whole timing table has.
109+
for (const key of ['navigationBarHideShowMs:', 'keyboardNotificationMs:']) {
110+
expect(text).not.toContain(key);
111+
}
112+
});
105113
});

0 commit comments

Comments
 (0)