Closed IvanAddolorato closed 4 years ago
@IvanAddolorato Do you just want callbacks here or do you need with data ? Like oldIndex
, newIndex
Thanks for quick reply.
I need the data to make some actions based on it.
@IvanAddolorato You can use it this way. https://github.com/m-inan/react-upload-gallery/commit/a2090a2855e01bc79ae9fdd5e58043dd5957b663
<Rug
onSortEnd={(images: any, diff: any) => {
console.log(images, diff);
}}
/>
I would be very glad if you can test it on the last commit and return it. Then I can add the feature to the document and send it as a new package.
I have just tested it and works perfect.
From my side, this is ready to be packaged and released.
Thanks so much!
Thanks for the suggestion. You can use the feature with the 0.2.0
version.
Great!
Hello @m-inan
First, I want to thank you for such a great component. It is very flexible and easy to use.
This issue is due the impossibility to use the sorting callback onSortEnd, as it explicitly overriden in the line referenced below:
https://github.com/m-inan/react-upload-gallery/blob/e21bdeb76e68dbedbc0b7e34ae27f520bf2392b0/src/DragArea.js#L19
I think that this can be solved by doing something like:
onSortEnd={(params, e) => { setSort(arrayMove(images, params.oldIndex, params.newIndex)); props.onSortEnd(params, e); }}
What do you think?
Thanks and looking forward for an answer.
Ivan.-