Open alvaro1728 opened 3 years ago
Hi Alvaro,
I'll start this reply with my standard apology for the state of maintenance of this library right now. Personal circumstances have not afforded me the time to do any deep work on Drax for a while, and I am not fresh on the code. I have a Drax logic documentation project in progress but presently on hold. The goal with that is to make it easier for myself and others to maintain the library without accidentally breaking or changing functionality. I do however keep an eye on the issues and try to answer things off the top of my head if I am able.
Unfortunately, this sounds to me like a feature request and not something currently provided by the library. The main DraxView gesture logic is implemented with a LongPressGestureHandler as seen here:
I believe it would require us to add a TapGestureHandler and to ensure that the two would interoperate without clobbering each other, but that might be easier said than done. Getting the gesture handler logic functioning was always fraught and involved various workarounds. I have not worked on this logic or experimented with react-native-gesture-handler in quite a while though, so I am not sure what the latest state of that library is or whether things might go more smoothly now.
Hi Joe,
Thanks for your thorough reply. I hope your circumstances change and you're able to devote more time to this great library, which I'm putting to use as we speak. A Tap (or Press) GestureHandler sounds like the right approach. In the mean time, I'm going to find some sort of workaround. One that comes to mind is storing the current time in onDragStart and checking it against the current time in onDragEnd. If the difference is smaller than say 100 (ms), then I can treat it as a tap.
Thanks again, Alvaro
You'll need to lower the longPressDelay for that workaround, which may give you trouble if it's too low. Hope you can make it work!
In case anyone's looking for a working solution to this, here's what I did. In my case, I have my DragViews already over a receiver DraxView so I checked for drag activity using the onDragStart
, onDragOver
, and onDragDrop
handlers. I used the DraxViews payload
to keep track of whether it's being dragged. So here it is:
<DraxView
payload={someObject}
onDragStart={() => someObject.dragged = false}
onDragOver={event => {
if (event.dragTranslation.x || event.dragTranslation.y) {
someObject.dragged = true;
}
}}
onDragDrop={event => {
if (!someObject.dragged) {
onEdit(someObject);
}
}}>
...
</DraxView>
Cheers, Alvaro
Thanks, Alvaro. I'm going to keep this issue open as a feature request for the future.
Hi, I want to detect when the user just taps on the DraxView. I would interpret that as him wanting to edit the contents, not drag it around. That's typically done via an onPress event handler. Is there something similar here?
Thanks, Alvaro