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 b19e233
Browse filesBrowse the repository at this point in the historyBrowse files
[iOS] Report zero Pan velocity when the pointer rested before release (#4642)
## Description
Follow-up to the web fix for #4636, same rule on iOS and macOS.
The Pan handler reports UIKit's `velocityInView:` in every event,
including the end event. That estimate freezes at the last touch move,
so a drag that stops, holds still, and then lifts reports the velocity
of the drag in `onEnd`, and a `withDecay` started from it flings a
pointer that had come to rest. Android reports 0 in that case, since its
`VelocityTracker` treats a pointer as stopped after 40 ms without a
sample.
`RNBetterPanGestureRecognizer` now stamps the time of every move and, on
release, records whether more than 40 ms passed since the last move. The
check runs before the superclass handles the release, because that is
where the gesture ends and the action is dispatched. The event payload
reads the velocity through `reportedVelocityInView:`, which returns zero
in the ended state after such a rest and UIKit's estimate otherwise.
Update events, activation criteria and failure paths are unchanged, and
so is a release within 40 ms of the last move.
## Test plan
Tested on "Velocity Test" example
- iPhone 17 simulator, v3 `usePanGesture` screen, a 160 px drag in 48 ms
driven with argent: released at the last move `velocityX` 2517, released
19 ms later 2587, released 500 ms later 0 (2657 before the change).
- macOS and tvOS share the change and compile the same paths, not run on
a device.
0 commit comments