Skip to content

Commit 37ee506

Browse files
committed
feat(core): one tracker for a held finger across any group of targets
`createActionGroupTracker` (hooks/actionGroupTracker.ts), exported from `@astryxdesign/core/hooks` as experimental with `ActionGroupTracker`, `ActionGroupTrackerOptions` and `ActionGroupTarget`: UIKit's tracking of a held finger across a group of targets, as a plain object any gesture recognizer can drive, so an alert's or an action sheet's actions, a menu's rows, a segmented control's segments and a page control's dots share one implementation instead of each resolving, painting and activating the target under the finger itself. - `begin` reads the targets' rects once; `move` resolves the finger against them (the hit test grown by `highlightExpansion`, or the owner's `resolveTarget(x, y, targets)`: the nearest segment along an axis, the end one past the ends) and never reads layout; `offsetBy` and `remeasure` follow content that moves under a still finger. - The highlighted target is painted with the press attribute (or not: `paintsHighlight: false`) and reported with the one it replaces (`onHighlightChange(next, previous)`); `beganOn` is the target the press began on; `onMove(x, y)` sees every position first. - `end` fades the paint and runs the target through its own `click()` inside the lift's event (or `onActivate`); `onActivated(item, cancelled)` learns whether a handler's `preventDefault()` vetoed it, and `swallowsNativeClick` takes the browser's own click for an unclaimed touch once, with listeners that exist only until that click, the next press or a key. - An inert press is taken but tracks nothing; disabled targets are skipped; `dispose` finishes pending fades.
1 parent 2763bcc commit 37ee506

4 files changed

Lines changed: 934 additions & 0 deletions

File tree

‎.changeset/action-group-tracker.md‎

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+
[experimental] `createActionGroupTracker` (with `ActionGroupTracker`, `ActionGroupTrackerOptions` and `ActionGroupTarget`) is exported from `@astryxdesign/core/hooks`: one tracker for a held finger across a group of targets (an alert's or an action sheet's actions, a menu's rows, a segmented control's segments, a page control's dots). It reads the targets' rects once, resolves the finger against them (or by the owner's rule), paints or reports the highlight, and runs the target through its own click at the lift.
6+
7+
@vjeux

0 commit comments

Comments
 (0)