nuclearpasta / react-native-drax

A drag-and-drop system for React Native
MIT License
554 stars 69 forks source link

Can't use long press on list item #96

Open likon416 opened 3 years ago

likon416 commented 3 years ago

Currently, if we would like to have a list item that is using the long press for example to mark things as done we can't. Drag & drop functionality kicks in and percent from using long press in our item component.

Would be good to be able to pass down the event, or create functionality that drag & drop only works if I will click on the specific part of my list item, for example, a specific icon rather than the whole item.

lafiosca commented 3 years ago

Thanks for the feature request. It occurs to me that this behavior is not specific to DraxList and this enhancement could apply to regular DraxViews as well.

Right now, we rely on a LongPressGestureHandler to determine when a DraxView is being dragged, even when the longPressDelay is set very low. This is partly because at the time this library was first developed, PanGestureHandler had limitations which prevented it from meeting our needs, and it is partly because the DraxList use case needs a way of distinguishing between gestures intending to scroll the list versus drag an item. I have not recently researched the state of react-native-gesture-handler to see if there are any relevant changes since then.

Effectively though for this feature, we will need a way of distinguishing between a long press intended to drag an item and a long press intended to do something else. My first thought is that we would continue to use a LongPressGestureHandler and distinguish between two different longPressDelay values to respond dynamically.

The second idea you suggest sounds to me like a distinct feature request which might be worth opening another issue for. Essentially it would mean the library needs some way to specify a drag handle for a DraxView. That one would likely require some deeper thought and experimentation.