如何在 React-Native 中停止触摸事件传播 [英] How to stop touch event propagation in React-Native

查看:25
本文介绍了如何在 React-Native 中停止触摸事件传播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我长按图像时,我有一个带有图像网格的滚动视图,我想停止将鼠标事件传播到滚动视图并只监视移动.意图在按下时重新初始化传播.有人知道怎么做吗?

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 intent to re-initialize propagation on press out. Anyone know how?

推荐答案

你应该看看 Gesture Responder 的方法:https://facebook.github.io/react-native/docs/gesture-responder-system.html#responder-lifecycle.实际上,更简单的方法是查看 PanResponder https://facebook.github.io/react-native/docs/panresponder.html - 首先查看 UIExplorer 示例以查看它的运行情况:https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ResponderExample.js.我不确定这是否能处理你的长按案例?

You should take a look at the Gesture Responder's methods: https://facebook.github.io/react-native/docs/gesture-responder-system.html#responder-lifecycle . Actually even simpler way will be to take a look at the PanResponder https://facebook.github.io/react-native/docs/panresponder.html - first see the UIExplorer example to see it in operation: https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ResponderExample.js . I am not sure though if this will handle the long-press case of yours?

这篇关于如何在 React-Native 中停止触摸事件传播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆