Making touchableopacity onPress work
ToshKoevoets opened this issue · 0 comments
ToshKoevoets commented
To make Touchable opacity work it's necessary to add some logic to the PanResponder.
Adding check on onMoveShouldSetPanResponder & onMoveShouldSetPanResponderCapture seems to work.
```
const shouldStartDrag = (gs) => { return (Math.abs(gs.dx) > 2 || Math.abs(gs.dy) > 2)};
this.panResponder = PanResponder.create({
onMoveShouldSetPanResponder: (_, gestureState) =>
shouldStartDrag(gestureState),
onMoveShouldSetPanResponderCapture: (_, gestureState) =>
shouldStartDrag(gestureState),
onPanResponderMove: (e, gesture) => {
const { pageX, pageY } = e.nativeEvent;
this.props.__dndContext.handleDragMove(this.identifier, {
x: pageX,
y: pageY
});
this.moveEvent(e, gesture);
},
onPanResponderStart: e => {
const { pageX, pageY } = e.nativeEvent;
this.props.__dndContext.handleDragStart(this.identifier, {
x: pageX,
y: pageY
});
},
onPanResponderRelease: e => {
const { pageX, pageY } = e.nativeEvent;
if (this.props.bounceBack) {
Animated.spring(this.state.pan, {
toValue: { x: 0, y: 0 }
}).start();
}
this.props.__dndContext.handleDragEnd(this.identifier, {
x: pageX,
y: pageY
});
}
});
}