nuclearpasta / react-native-drax

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

Cancel dragging #101

Open iluretar opened 3 years ago

iluretar commented 3 years ago

Is it possible to programatically cancel the dragging, for example if the payload meet some criteria?

lafiosca commented 3 years ago

@iluretar Off the top of my head I do not recall a way to do this, but others may have experimented more recently than me. For now I am marking this issue as an enhancement request.

lafiosca commented 3 years ago

One thing that just occurred to me was that perhaps making the dragged item have draggable={false} might do it... but I don't think it would. I suspect that is only checked when the drag begins.

jaehak9078 commented 2 years ago

In my case, I needed to prevent dragging of only certain items in DraxList, and the method I used is as below code <DraxList ... itemsDraggable={draggable} onItemDragStart={(e) => { e.item.type === 'title' && setDraggable(false); }} onItemDragEnd={(e) => { e.item.type === 'title' && setDraggable(true); }} ... />