如何将平移响应器仅移动到顶部和左侧方向

How to move pan responder to only top and left direction

如何限制平移的移动区域只响应向上(顶部)和左侧?

我目前正在这样做,但没有成功!

this.state = 
{
  pan: new Animated.ValueXY()
}    

let eventMoveLeft = Animated.event
(
  [null, { dx: this.state.pan.x}]
);

let eventMoveTop = Animated.event
(
  [null, { dy: this.state.pan.y}]
);

onPanResponderMove: (e, gesture) => {
if (this.state.isAnimated) {
      return gesture.dx < gesture.dy ? eventMoveLeft(e, gesture) : eventMoveTop(e, gesture);
    }
  },

在 onPanResponderMove 事件上获取设备的高度并以百分比形式限制您想要的距离,就像这样...

 Math.abs(gesture.dy) > HEIGHT_DEVICE * .16 ? null : this.state.pan.y.setValue(gesture.dy);