react-native-pull-to-refresh-custom
react-native-pull-to-refresh-custom copied to clipboard
最大下拉距离
您好 想问一下 如果想限制 最大下拉距离应该在那个位置处理呢
Hi, I am able to set it at onPanResponderMove method, using this.props.maxScrollHeight passed in from outside
onPanResponderMove(event, gestureState) {
console.tron.log(gestureState.dy);
if (gestureState.dy < this.props.maxScrollHeight) {
if (gestureState.dy >= 0) {
// const dy = Math.max(0, gestureState.dy);
this.state.containerTop.setValue(gestureState.dy);
} else {
this.state.containerTop.setValue(0);
if (this.scrollRef) {
if (typeof this.scrollRef.scrollToOffset === 'function') {
// inner is FlatList
this.scrollRef.scrollToOffset({
offset: -gestureState.dy,
animated: true,
});
} else if (typeof this.scrollRef.scrollTo === 'function') {
// inner is ScrollView
this.scrollRef.scrollTo({
y: -gestureState.dy,
animated: true,
});
}
}
}
} else {
this.state.containerTop.setValue(this.props.maxScrollHeight);
}
}