Repository navigation
Commit 37ee506
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
- packages/core/src/hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments