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

Is it Possible to contain a draggable div to its parent #544

Closed lhalver1 closed 3 years ago

lhalver1 commented 6 years ago

Is there a way to contain a draggable item to its' parent div? It is similar to what JQuery has here https://api.jqueryui.com/draggable/#option-containment

4leem commented 6 years ago

Yes, you can provide accepts in the dragula options.

accepts: function (el, target, source, sibling) {
    return true; // elements can be dropped in any of the `containers` by default
}

You can check if target is same as el.parentElement. You can validate and return true/false.