如何在 React Native 中检测整个屏幕上的向左滑动?
是否有必要使用 PanResponder 还是可以更简单一点?
最佳答案
我发现 react-native-swipe-gestures
不稳定(滑动在 android 上随机运行)并且 react-native-gesture-handler
过于复杂(只是添加到项目中需要付出太多努力)。
基于 Kuza Grave 的答案的简化解决方案,谁的解决方案完美且非常简单:
<View
onTouchStart={e=> this.touchY = e.nativeEvent.pageY}
onTouchEnd={e => {
if (this.touchY - e.nativeEvent.pageY > 20)
console.log('Swiped up')
}}
style={{height: 300, backgroundColor: '#ccc'}}
/>
关于javascript - 在 React Native 中检测向左滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45854450/