I have a sortable list in which are several elements that need to be able to be reordered by the user.
Alternatively the elements can also be dragged onto 5 available dropzones (droppable containers).
The problem I am encountering is this: When the drop is successfully done on a droppable zone, the revert animation of the sortable is still playing animating the dropped element back into the sortable list.
Instead I would like to animate it in a way that the helper is taken from where the drop occurred and then animated into the droppable zone, sort of like dragging a file into the Trash on a Mac.
For the latter to work however I’d need to:
- On successful drop, stop the revert animation.
- Copy the coordinates of the dropped element and launch custom animation to the center of the droppable element.
The issue is within part (1), draggable allows the ‘invalid’ or ‘valid’ flags on revert but sortable doesn’t.
Any ideas on how I can achieve this?
So after a bit of back and forth I’ve managed to resolve this by cloning the original
ui.helperelement (thatsortablecreates) and using this clone (which isn’t being reverted back obviously) to finish the custom animation sequence while removing the original helper and placeholder (created bysortable) to hidesortable‘s revert animation.It’s not quite as clean as I would’ve preferred it because I’m effectively still letting the
sortable‘s revert function execute (rather than cancelling it) but until someone has a better idea this works.Code below: