ng2-dragula
ng2-dragula copied to clipboard
How cancel drop?
I tried to implement a list with disabled items. User can't move items before disabled or between disabled items. I need to prevent dropping an item in those cases.
I found issues: https://github.com/valor-software/ng2-dragula/issues/438 https://github.com/valor-software/ng2-dragula/issues/552
But it seems that in v2 this approach doesn't work. Stackblitz example: https://stackblitz.com/edit/ng2-dragula-base-kdvkzg
PS In general it would be great have an option 'cancelDropFn'/'allowDropFn' as a function that gets the same params as dropModel<Observable> and returns boolean.
If there is such function or option please let me know.
I would just put them in a different list that does not participate in dragging. Seeing as you just want all the frozen vamps to be before the draggable vamps.
Example:
constructor(private dragulaService: DragulaService) { this.dragulaService.createGroup('VAMPIRES', { moves: () => true }); }
ngOnDestroy(): void { this.dragulaService.destroy('VAMPIRES'); }