mohebifar / mohebifar/react-native-easy-dnd
Making touchableopacity onPress work
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 127
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
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
});
}
});
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PanResponder setup in the drag-and-drop component and review how its movement callbacks interact with TouchableOpacity's onPress. Reproduce a press and a drag, then verify that press callbacks still fire while dragging continues to work after the responder checks are adjusted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100