如何缩短 React Native 刷新控件中的刷新距离(阈值)
How do I shorten the pull to refresh distance (threshold) in React Native Refresh Control
我正在尝试使用 ScrollView 中的刷新控件实现下拉刷新。我需要修改刷新控件的拉动distance/threshold。我已经查了相关的道具来实现它,但是我找不到任何与此相关的道具。
<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
}
};
我正在尝试使用 ScrollView 中的刷新控件实现下拉刷新。我需要修改刷新控件的拉动distance/threshold。我已经查了相关的道具来实现它,但是我找不到任何与此相关的道具。
<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
}
};