bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
21.89k stars 1.97k forks source link

feature request for event `accepts`: provide dragged element new index in the target array #651

Closed slamjs closed 3 years ago

slamjs commented 3 years ago

currently, in the accepts event I can't know what index a dragged element will have after dragging to the target array, but I need this for a validation purposes. I want to allow to drag an element only to certain range of indexes in the target array, that range of indexes will be dynamic based on the current array state and elements that it's contain.

It would be very helpful if an accepts event will be changed to something like accepts: function (el, target, source, sibling, newIndex) {}

dcantatore commented 3 years ago

You can determine the new index based on the sibling.