How to disable drag some element on ng2-dragula
find a solution:
dragulaService.setOptions('nested-bag', {
revertOnSpill: true,
moves: function (el:any, container:any, handle:any):any {
debugger
console.log(el, container);
return false;
}
});
To disable dragging element with specific class:
dragulaService.setOptions('PUT_CONTAINER_NAME_HERE', {
moves: function (el: any, container: any, handle: any): any {
if (el.classList.contains('PUT_YOUR_CLASS_HERE')) {
return false;
}
return true;
}
});
Since Version 2 (released 2018-07-19) you should use dragulaService.createGroup()
instead of dragulaService.setOptions()
:
dragulaService.createGroup('<container-name>', {
moves: (el, container, handle, sibling) => false
});