bevacqua / dragula

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

Restrict few elements to get dropped. #570

Closed yakshit15 closed 4 years ago

yakshit15 commented 6 years ago

Like Microsoft Excel Pivot Mode, where we have 4 panels and it has the ability to drag and drop elements. I want to restrict few elements to get moved based on the condition of my JSON.

mostafaebrahimi commented 6 years ago

you must use move function and restrict elements from moving (or show some info to your users)

dragula(containers, {
    moves: function (el, source, handle, sibling) {
        if(condition) //needed condition
            return true //if el can move
        else 
           return false // if el can not move
    },
    accepts: function (el, target, source, sibling) {
        if(condition) //needed condition
            return true //if el can dropped 
        else 
           return false // if el can not dropped
    },
});