Skip to content
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

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

Open
baiachen opened this issue Oct 26, 2021 · 10 comments
Open

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

baiachen opened this issue Oct 26, 2021 · 10 comments

Comments

@baiachen
Copy link

react-native-largelist 3.1.0-rc.2

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

@anyway2019
Copy link

动态设置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
Copy link
Author

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

@bolan9999
Copy link
Owner

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

@bolan9999
Copy link
Owner

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

@bolan9999
Copy link
Owner

onStartShouldSetResponderCapture

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

@zouyaozhen1234
Copy link

也遇到了 都咋解决的

@MaratSHU
Copy link

    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

@chj-damon
Copy link

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

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

@chenshaxuanjing
Copy link

请问有解决办法么

@oofavor
Copy link

oofavor commented Apr 9, 2022

Any solution for high sensitivity so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants