-
Notifications
You must be signed in to change notification settings - Fork 399
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
Random onPress handle in FlatList items while swiping pages #424
Comments
Face the same issue with ios + hermes on. |
For more information In the past, i'v use But currently when try ios build, this problem occured. I'v also update to The only solution that work for me now is listen for |
Depending on the type of touchable component you're using, you should be able to use the P.S. While the react-native-gesture-handler docs say that TouchableWithoutFeedback and the like are drop-in replacements for the regular React-Native components, there are a few annoying differences regarding layout like this. |
I have this problem on Android, and ignoring |
I use I guess it's because of the async between the |
Any update? |
@grabbou Could we get an update on this please? |
Found a solution! // FixedTouchableHighlight.js
import React, { useRef } from 'react';
import { TouchableHighlight } from 'react-native';
export default function FixedTouchableHighlight({
onPress,
onPressIn,
...props
}) {
const _touchActivatePositionRef = useRef(null);
function _onPressIn(e) {
const { pageX, pageY } = e.nativeEvent;
_touchActivatePositionRef.current = {
pageX,
pageY,
};
onPressIn?.(e);
}
function _onPress(e) {
const { pageX, pageY } = e.nativeEvent;
const absX = Math.abs(_touchActivatePositionRef.current.pageX - pageX);
const absY = Math.abs(_touchActivatePositionRef.current.pageY - pageY);
const dragged = absX > 2 || absY > 2;
if (!dragged) {
onPress?.(e);
}
}
return (
<TouchableHighlight onPressIn={_onPressIn} onPress={_onPress} {...props}>
{props.children}
</TouchableHighlight>
);
} |
@Gregoirevda Thank you for the workaround. Hopefully this is a temporary fix and a future update will prevent touchable from activating during screen transitions. |
I have the same problem on React Navigation v6 |
Still an issue +1 |
Thank you @Gregoirevda for providing a temporary solution 🙏 it works! I even used it as
|
I just patched it react-native-tab-view/src/PanResponderAdapter.tsx const panResponder = PanResponder.create({
}); I hope it helps someone |
Environment
expo v42.0.0
"react-native-pager-view": "5.4.0"
Description
Random onPress handle in FlatList items while swiping pages
Especially noticeable on low-end android devices and in apps with many heavy components
Reproducible Demo
There is a function in demo that imitate CPU intensive operation
in order for the issue to be stably reproduced in simple demo on high-end devices
https://snack.expo.dev/@sane.ecg/pager-onpress-issue
video_2021-08-08_00-58-55.mp4
The text was updated successfully, but these errors were encountered: