mgcrea / react-native-dnd

Modern and easy-to-use drag&drop library for react-native.
https://mgcrea.github.io/react-native-dnd/
MIT License
135 stars 12 forks source link

Is there a way to show position of sorting? #11

Closed Rc85 closed 6 months ago

Rc85 commented 9 months ago

Like this?

jtc3161 commented 8 months ago

Are you talking about the flatlist example? The useDraggableGrid hook contains an onOrderChanged callback that responds with the new list ordering when you drop the object in it's new position.

brannonvann commented 8 months ago

@jtc3161 Do know where the documentation might be for useDraggableGrid? I noticed several things exist (DraggableFlatList and several hooks) without documentation.

I've been trying implement something similar to the "Demo" here but I don't see how the Demo is possible with the documented functionality. Specifically, making space where the droppable item will go and then handling the new order once it's dropped. Regarding the question here, I assume @Rc85 also wants the same thing.

mgcrea commented 6 months ago

I've re-written the draggable grid from the ground up and I'm currently improving the docs.

There is now two easy-to-use components DraggableStack and DraggableGrid.

The draggable stack can only sort on a single axis but handles variable width. Probably what you want. I also have a DraggableFlatList in the works but there is still some issues when trying to sort out of bounds in specific situations.

I have added updated examples here: https://github.com/mgcrea/react-native-dnd/tree/master/example/src/pages

Let me know if there is anything unclear.