reactjs - 如何缩短 React Native Refresh Control 中的拉动刷新距离(阈值)
问题描述
我正在尝试使用 ScrollView 中的刷新控件来实现拉动刷新。我需要修改刷新控制的拉距/阈值。我已经检查了相关的道具来实现它,但我找不到任何与此相关的道具。
<ScrollView
contentContainerStyle={styles.subContainer}
bounces={true}
horizontal={false}
refreshControl={
<RefreshControl
refreshing={false}
tintColor={'transparent'}
onRefresh={() => {
onSwipeDown();
}}
/>
}
>
{props.children}
</ScrollView>
请帮帮我。
解决方案
我们可以通过 onScroll 事件监听器来实现。
<ScrollView
contentContainerStyle={styles.subContainer}
bounces={true}
horizontal={false}
onScroll={onSwipeDown}
>
{props.children}
</ScrollView>
onSwipeDown 方法
const onSwipeDown = event => {
console.log(event.nativeEvent.contentOffset.y);
if (event.nativeEvent.contentOffset.y < 0) { // you can replace zero with needed threshold
onRefresh(); //your refresh function
}
};
推荐阅读
- javascript - 我需要 selenium 来检查一个框,但我不能检查它
- c++ - 好友功能无法访问私人会员
- css - 如何在material-ui表格分页中改变样式
- javascript - 选择不工作的反应下拉默认值
- c++ - 在 C++ 中创建动态内核调度程序
- python - IndentationError: 意外缩进 Python timeit() 方法
- python - 上传的图片未在 html 上显示
- javascript - 我的节点应用程序在 localhost 上运行良好,但是当我部署在 heroku 上时,它给了我应用程序错误。你可以阅读下面的描述
- android-studio - Android Studios 中未解决的参考
- javascript - 如何在 JavaScript 中将用户重定向到考试页面?