4

If you want to drag and drop an element with PanResponder, you could pass the values of the movement to the onPanResponderMove method in two ways:

1. With Animated.Event

onPanResponderMove: Animated.event([
    null,
    { dx: this.state.pan.x, dy: this.state.pan.y }
]),

2. With .setValue

onPanResponderMove: (evt, gesture) => {
    this.state.pan.setValue({x: gesture.dx, y: gesture.dy})
},

Both appear to do the same thing in my tests. What is the difference?

Klemens159
  • 171
  • 1
  • 11

0 Answers0