-
-
Notifications
You must be signed in to change notification settings - Fork 576
feat: add screen "go back" transition animations based on gestures using Reanimated #1913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jul 17, 2024
This was referenced Jul 25, 2024
ja1ns
pushed a commit
to WiseOwlTech/react-native-screens
that referenced
this pull request
Oct 9, 2024
## Summary This pull request introduces a new feature which adds screen "go back" transition animations based on gestures. The feature is a collaboration between three libraries: `react-native-reanimated`, `react-native-screens`, and `react-native-gesture-handler`. Implementing this feature required changes in both Reanimated and RNScreens. You can find the related pull request in the `react-native-reanimated` repository: [PR 1913](software-mansion/react-native-reanimated#5274). ## Test plan Test example from Example App --------- Co-authored-by: Krzysztof Piaskowy <[email protected]>
ja1ns
pushed a commit
to WiseOwlTech/react-native-screens
that referenced
this pull request
Oct 9, 2024
…nsion#2017) ## Description Unfortunately, because of changing the way how we export the components, I didn't saw the wrong export of GHContext in gesture-handler's `index.tsx` file. To match the changes from the PR with full screen swipe (software-mansion#1913), I've created the directory in a wrong place. This PR fixes this export by moving the context to native-stack and removing the export from the gesture-handler/index.tsx. I'm also removing this export, because right now it's possible to import GHContext from `react-native-screens` and also from `react-native-screens/gesture-handler` which is wrong. ## Changes - Changed the export of GHContext in index.tsx - Moved GHContext from gesture-handler to native-stack ## Test code and steps to reproduce Try to build and run TestsExample - see if the bundling state passes correctly. Then, try to import GestureDetectorProvider and wrap whole navigator in it. ## Checklist - [X] Included code example that can be used to test this change - [x] Ensured that CI passes
2 tasks
kkafar
added a commit
that referenced
this pull request
Mar 31, 2025
…ndler` is present (#2819) ## Description When `GestureHandler` & `GestureHandlerRootView` are present, the pressables in subtree of `GestureHandler` will lose focus on fast initial movement. See the video below 👇. > [!note] > Edit: the *fast movement* requirement most likely comes from the fact that we use `fling` for the `EmptyGestureHandler`. In case you use e.g. `Pan`, the movement does not have to fast. > [!note] > The issue is reproducible **w/o** `react-native-screens`. The issue affects us, because #1913 added custom-screen-transitions based on integration with `gesture-handler` & `reanimated`. Each `ScreenStack` is since then wrapped in a `GestureDetector`, which uses either [`EmptyGestureHandler`](https://github.com/software-mansion/react-native-screens/blob/4d044dab8c387c6f3988434276594a2d917f5022/src/gesture-handler/ScreenGestureDetector.tsx#L27) or [one defined based on gesture config](https://github.com/software-mansion/react-native-screens/blob/4d044dab8c387c6f3988434276594a2d917f5022/src/gesture-handler/ScreenGestureDetector.tsx#L247). ### Issue mechanism Basically it seems like bug in `gesture-handler`. The `RNGestureHandlerRootHelper` [cancels gesture](https://github.com/software-mansion/react-native-gesture-handler/blob/4232fc3127949c2869769542bfc7c3710b1348ee/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt#L87) on the root view, causing RN pressable gesture handling to be cancelled. Instead, the attached gesture-handler intercepts the touch events. > [!warning] > I was able to reproduce the issue 100% reliably earlier w/o presence of the `Screen` component, however > testing it now it seems that the `Screen` is required (w/o `Screen` in view hierarchy it seems to work fine...). > Dunno what is going on 🤷 ### Issue recording https://github.com/user-attachments/assets/d0e9de2e-7d77-4379-b3f8-5da9e8b028ac ## Changes It looks to me that it has to be handled on the side of `gesture-handler` / `reac-native` core. Currently, I've decided to `disable` the `EmptyGestureHandler` we wrap the `ScreenStack`. > [!caution] > **This is only partial workaround**. There still will be issue in case someone setups the `goBackGesture` & we pass `enabled` `GestureHandler` to `GestureDetector`. ## Test code and steps to reproduce `Test2819`, may require you to wrap `HomeOne` inside a `Screen`, depending on the device/RN/other code mood I guess. ## Checklist - [x] Included code example that can be used to test this change - [ ] Ensured that CI passes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces a new feature which adds screen "go back" transition animations based on gestures. The feature is a collaboration between three libraries:
react-native-reanimated
,react-native-screens
, andreact-native-gesture-handler
. Implementing this feature required changes in both Reanimated and RNScreens. You can find the related pull request in thereact-native-reanimated
repository: PR 1913.Dependency requirements:
[email protected]+
[email protected]+
react-native-gesture-handler@2+
A demo of this feature was presented at the RNCK meetup: RNCK Meetup Demo
API Overview
Basic usage
To use this feature, you need to import the
GestureDetectorProvider
fromreact-native-screens/gesture-handler
and wrap your navigation container with it. Here's an example:Available gestures:
Preset usage
You can also use preset animations for the transition. Import
ScreenTransition
fromreact-native-reanimated
and specify the desired preset in thetransitionAnimation
option. Example:Available presets:
You don't need to worry about the preset because each gesture is associated with a default transition preset.
Custom Animation
If you want to create a custom animation, you can define your own
AnimatedScreenTransition
object. Here's an example:screenEdgeGesture
To trigger a gesture that starts from the edge of the screen, you can use the
screenEdgeGesture
option. Example:This means you can trigger a transition with a gesture that starts from the edge of the screen.
Test plan
Test example from Example App