react-native-pull-to-refresh-custom icon indicating copy to clipboard operation
react-native-pull-to-refresh-custom copied to clipboard

最大下拉距离

Open potatoes0521 opened this issue 5 years ago • 1 comments

您好 想问一下 如果想限制 最大下拉距离应该在那个位置处理呢

potatoes0521 avatar Sep 25 '20 09:09 potatoes0521

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);
    }
  }

kyaroru avatar Jan 05 '21 11:01 kyaroru