如何使用PanResponder获取对象

时间:2018-10-05 18:14:50

标签: javascript react-native

这是我的代码:

  componentWillMount() {


    this._panResponder = PanResponder.create({
      onStartShouldSetPanResponder: (e,gs) => true,
      onStartShouldSetPanResponderCapture: (e,gs) => true,
      onMoveShouldSetPanResponder: (e,gs) => true,
      onMoveShouldSetPanResponderCapture: (e,gs) => true,
      onPanResponderMove: (e,gs) => {
        let xOrigin = this.props.xCenter - (this.props.dialRadius + this.props.btnRadius + 50);
        let yOrigin = this.props.yCenter - (this.props.dialRadius + this.props.btnRadius + 50);
        let a = this.cartesianToPolar(gs.moveX-xOrigin, gs.moveY-yOrigin);
        this.setState({angle: a});
      },
      onPanResponderTerminate: (evt, gestureState) => {
          console.log("test")
        },
    });
  }

我为不同的SVG对象调用PanResponder

我想知道哪些对象称为onPanResponderTerminate函数。

      <G x={endCoord.x-widthHeight} y={endCoord.y-widthHeight}>
        <Circle
          r={widthHeight}
          cx={widthHeight}
          cy={widthHeight}
          fill={this.props.meterColor}
          {...this._panResponder.panHandlers}/>

      </G>

      <G x={endCoord.x-widthHeight} y={endCoord.y-widthHeight}>
        <Circle
          r={widthHeight}
          cx={widthHeight}
          cy={widthHeight}
          fill={this.props.meterColor}
          {...this._panResponder.panHandlers}/>

      </G>

0 个答案:

没有答案