react-native - react native gesture touch point capture issue
问题描述
I want to get touch points for gestures. When I do it on the same page (touch the screen on a location and move my finger to another location) the below function perfectly works. ( I can get the starting touchpoint and the ending touchpoint)
panResponder = PanResponder.create({
onStartShouldSetResponder: () => true,
onMoveShouldSetPanResponder: () => true,
onPanResponderGrant: (evt, gestureState) => {
console.log(evt.nativeEvent, '........', gestureState);
},
onPanResponderRelease: (evt, gestureState) => {
console.log(evt.nativeEvent, '........................', gestureState);
},
});
render() {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Swiper loop={false} showsPagination={false} index={1}>
<View style={styles.textInput}>
<Button
title="Type"
onPress={() => this.props.navigation.navigate('Keystroke')}
/>
</View>
<Swiper
{...this.panResponder.panHandlers}
horizontal={false}
loop={false}
showsPagination={false}
index={1}>
<View style={styles.textInput}>
<Text>Swipe left to select typing</Text>
<Text>Swipe right to select gestures</Text>
</View>
</Swiper>
</Swiper>
</View>
);
}
But, I need to get the starting(onPanResponderGrant) and ending(onPanResponderRelease) coordinates when swiping the screen.
I am using
Import Swiper from 'react-native-swiper';
Here, the starting touchpoint captures. But the ending touchpoint does not capture.
Can someone help me to figure out this issue? Thank you
解决方案
使用 onPanResponderEnd 而不是 onPanResponderRelease
推荐阅读
- javascript - 如何在单击时清除按钮上的日期范围选择器值?
- amazon-s3 - 具有 IAM 用户权限的 AWS PHP 预签名 URL
- visual-studio-code - 如何在 VS Code 的集成终端中将 ctrl+f 发送到 shell?
- node.js - 带有节点 x86 的 PKG
- python - 使用烧瓶从表单中读取 pdf 的 TypeError
- reactjs - 使用其他路由 React 在主页上渲染面板
- php - 使用 Laravel 8 +sail + docker 安装 Sql Server
- or-tools - 如何在创建变量期间加速 Ortools
- sharepoint - 获取 microsoft graph api 的 item-id
- mongodb - 将字符串与 MongoDB 中的对象连接起来