How to stop touch event propagation in React-Native

前端 未结 5 1123
南笙
南笙 2021-02-05 09:12

I have a scrollview with a grid of images when I long press on an image I’d like to stop propagating the mouse events to the scrollview and just monitor the movements. With the

5条回答
  •  生来不讨喜
    2021-02-05 09:54

    In my case, the onPress of the outer touchable was invoked first, even though I pressed the inner touchable.

    What I did, was to use the onPressIn and onPressOut in the inner touchable to determine whether the user pressed the inner or outer touchable - by setting a flag in the component class, on onPressIn and clearing it on onPressOut, and then checking for that flag in the onPress handler of the outer touchable, bailing out if it's set.

提交回复
热议问题