Skip to content

Commit

Permalink
fix: make stack navigator work with latest gesture handler (#10270)
Browse files Browse the repository at this point in the history
With the release of Gesture Handler 2 some gesture handlers have been updated to follow state-flow more consistently across the platforms. Among them was the Pan gesture which was changed to transition to the `BEGAN` state as soon as finger touches the screen opposed to just before transitioning to the `ACTIVE` state.
`@react-navigation/stack` is relying on the old behavior which may be causing some unexpected issues in apps, for example: software-mansion/react-native-gesture-handler#1801.

This PR changes the swipe-back gesture to start when the Pan transitions to the`ACTIVE` state. Since previously Pan gesture was transitioning to the `BEGAN` state just before transitioning to the `ACTIVE` state this change would be compatible with older versions of Gesture Handler.
  • Loading branch information
j-piasecki authored Jan 26, 2022
1 parent d0f8620 commit 5a19877
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default class Card extends React.Component<Props> {
} = this.props;

switch (nativeEvent.state) {
case GestureState.BEGAN:
case GestureState.ACTIVE:
this.isSwiping.setValue(TRUE);
this.handleStartInteraction();
onGestureBegin?.();
Expand Down

0 comments on commit 5a19877

Please sign in to comment.