react-native-largelist icon indicating copy to clipboard operation
react-native-largelist copied to clipboard

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

Open baiachen opened this issue 3 years ago • 10 comments

react-native-largelist 3.1.0-rc.2

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

baiachen avatar Oct 26 '21 02:10 baiachen

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

                    }}
                />

anyway2019 avatar Oct 27 '21 01:10 anyway2019

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

baiachen avatar Oct 27 '21 02:10 baiachen

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

bolan9999 avatar Oct 27 '21 02:10 bolan9999

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

bolan9999 avatar Oct 27 '21 02:10 bolan9999

onStartShouldSetResponderCapture

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

bolan9999 avatar Oct 27 '21 02:10 bolan9999

也遇到了 都咋解决的

zouyaozhen1234 avatar Oct 27 '21 12:10 zouyaozhen1234

    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

MaratSHU avatar Oct 27 '21 15:10 MaratSHU

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

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

chj-damon avatar Dec 13 '21 09:12 chj-damon

请问有解决办法么

chenshaxuanjing avatar Jan 27 '22 05:01 chenshaxuanjing

Any solution for high sensitivity so far?

oofavor avatar Apr 09 '22 20:04 oofavor