bolan9999 / react-native-largelist

The best large list component for React Native.
https://bolan9999.github.io/react-native-largelist/
MIT License
2.32k stars 261 forks source link

LargeList中使用TouchableOpacity滚动时触发onPress事件 #460

Open baiachen opened 3 years ago

baiachen commented 3 years ago

react-native-largelist 3.1.0-rc.2

存在的问题:换成LargeList中组件后,和TouchableOpacity组件使用滚动时很容易触发onPress事件, 换成 react-native-gesture-handler 1.10.3 之后,Ios表现正常,Android 还是存在

anyway2019 commented 3 years ago

动态设置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);

                    }}
                />
baiachen commented 3 years ago

这个组件确实很棒,列表滚动流畅了很多 但是如果滚动的时候触发onPess这个问题得不到很好的解决很难用到生产啊

bolan9999 commented 3 years ago

最近在出全新版本,没有时间改这个。全新版本用reanimated2,有更多操作空间

bolan9999 commented 3 years ago

以前都没人说这个问题,最近很多人说,我感觉应该是rn官方改了有关手势的一些东西导致的问题

bolan9999 commented 3 years ago

onStartShouldSetResponderCapture

最新版本SpringScrollView不是有这个玩意吗?

zouyaozhen1234 commented 3 years ago

也遇到了 都咋解决的

MaratSHU commented 3 years ago
    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:

Hope it will help someone too

chj-damon commented 2 years ago

最近在出全新版本,没有时间改这个。全新版本用reanimated2,有更多操作空间

大佬,新版本什么时候出啊,眼馋!

chenshaxuanjing commented 2 years ago

请问有解决办法么

oofavor commented 2 years ago

Any solution for high sensitivity so far?