小编Ale*_*sov的帖子

如何处理PanResponder长按事件?

我试图通过PanResponder处理React Native中的长按.经过一番体面的搜索,我无法找到"正确的方式",所以我在这里问.这个想法是在检测到屏幕上的长按(点击)时执行代码.我有这样的事情:

handlePanResponderGrant(e, gestureState){
    // On the press of the button set a timeout
    myVar = setTimeout(this.MyExecutableFunction(), LONG_PRESS_MIN_DURATION);
}

handlePanResponderRelease(e, gestureState) {
    // Clear the timeout if the press is released earlier than the set duration
    clearTimeout(myVar);
}
Run Code Online (Sandbox Code Playgroud)

这是处理长按的正确方法还是有更好的方法?

javascript react-native

6
推荐指数
1
解决办法
2362
查看次数

标签 统计

javascript ×1

react-native ×1