react-native-largelist
react-native-largelist copied to clipboard
LargeList中使用TouchableOpacity滚动时触发onPress事件
react-native-largelist 3.1.0-rc.2
存在的问题:换成LargeList中组件后,和TouchableOpacity组件使用滚动时很容易触发onPress事件, 换成 react-native-gesture-handler 1.10.3 之后,Ios表现正常,Android 还是存在
动态设置onStartShouldSetResponderCapture:
<LargeList {...listprops2}
onStartShouldSetResponderCapture={() => this._listViewDirtyPressEnabled_next}
onMomentumScrollBegin={() => {
if (!this._listViewDirtyPressEnabled_next) {
this._listViewDirtyPressEnabled_next = true
}
}}
onMomentumScrollEnd={() => {
setTimeout(() => {
if (this._listViewDirtyPressEnabled_next) {
this._listViewDirtyPressEnabled_next = false
}
}, 5);
}}
/>
这个组件确实很棒,列表滚动流畅了很多 但是如果滚动的时候触发onPess这个问题得不到很好的解决很难用到生产啊
最近在出全新版本,没有时间改这个。全新版本用reanimated2,有更多操作空间
以前都没人说这个问题,最近很多人说,我感觉应该是rn官方改了有关手势的一些东西导致的问题
onStartShouldSetResponderCapture
最新版本SpringScrollView不是有这个玩意吗?
也遇到了 都咋解决的
const pressable = useRef(true);
const onPhotoPress = (id) => {
if (pressable.current) {
Alert.alert('photo', id);
}
};
const onScrollStart = () => {
if (pressable.current) {
pressable.current = false;
}
};
const onScrollEnd = () => {
if (!pressable.current) {
setTimeout(() => {
pressable.current = true;
}, 10);
}
};
...
return (
<WaterfallList
...
onScrollBeginDrag={onScrollStart}
onMomentumScrollEnd={onScrollEnd}
/>
I compensate hypersensetivity using this code. Used TouchableOpacity
from 'react-native'
.
Pay attention:
- onScrollBeginDrag (not onMomentumScrollBegin) used for blocking touchable actions
- I set timout for 10 ms from the firs time and didn't change it. I think it will work with other values but it must be some timout for sure (without that, onPress fired on android in case when scrolling without lifting your finger from the screen)
Hope it will help someone too
最近在出全新版本,没有时间改这个。全新版本用reanimated2,有更多操作空间
大佬,新版本什么时候出啊,眼馋!
请问有解决办法么
Any solution for high sensitivity so far?