Touch events do not work when multiple screens are active on Android
See original GitHub issueI added a way to have transparent scenes in react-navigation a while back to support dialogs (https://github.com/react-navigation/react-navigation-stack/blob/master/src/views/StackView/StackViewCard.js#L35). It keeps all screens active in the stack but this seems to break touch events on Android because of the logic here: https://github.com/kmagiera/react-native-screens/blob/master/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.java#L189
The react-navigation code is basically this:
const modalNavigatorConfig = {
initialRouteName: 'app',
mode: 'modal',
headerMode: 'none',
transparentCard: true, // <- The option for transparent card
defaultNavigationOptions: {
gesturesEnabled: false,
},
transitionConfig: () => ({
transitionSpec: {
duration: 300,
easing: Easing.inOut(Easing.ease),
timing: Animated.timing,
},
screenInterpolator: sceneProps => {
const { position, scene } = sceneProps;
const { index } = scene;
const opacity = position.interpolate({
inputRange: [index - 1, index],
outputRange: [0, 1],
});
return { opacity };
},
}),
};
const ModalStack = createAppContainer(
createStackNavigator(
{
app: {
screen: RootStack,
},
{ screen: SomeOtherRoute },
},
modalNavigatorConfig,
),
);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:32
- Comments:43 (4 by maintainers)
Top Results From Across the Web
Manage touch events in a ViewGroup - Android Developers
Stay organized with collections Save and categorize content based on your preferences. Handling touch events in a ViewGroup takes special care, ...
Read more >Touch events - Web APIs - MDN Web Docs - Mozilla
Touch events are similar to mouse events except they support simultaneous touches and at different locations on the touch surface. The ...
Read more >Android Multi-touch event problems...No new ... - Stack Overflow
So yeah, the problem is that if the joystick is in the middle of a case MotionEvent.ACTION_MOVE it seems to block any other...
Read more >Gestures and Touch Events | CodePath Android Cliffnotes
Note that every touch event can be propagated through the entire affected view hierarchy. Not only can the touched view respond to the...
Read more >Touch & hold delay - Android Accessibility Help
"Touch & hold" is a common gesture on Android devices. It means that you touch an item on the screen and don't lift...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did a little expirement and changed this line from
Screen.java
:to :
This seems to resolve the issue as all the views will be able to receive touch events even when “transitioning” and I haven’t seen any side effects when it comes to performance. I might make a PR with a config to override the default behaviour of this method…
Think I’m seeing a similar issue on iOS: when navigating back to a previous screen in a stack that has transparentCard set, the screen doesn’t respond to touch events. Had a poke around with the Element Inspector and it seems that the component tree is “StackViewLayout > ScreenContainer” after navigating back, compared to “StackViewLayout > SceneView > [ Screen ]” initially. Navigation gestures still work, screen focus events still trigger and navigating from the screen via code is fine. Will investigate further and try to get a snack up and running asap