ng2-dragula icon indicating copy to clipboard operation
ng2-dragula copied to clipboard

How cancel drop?

Open dmkorol opened this issue 6 years ago • 2 comments
trafficstars

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.

dmkorol avatar Jan 24 '19 19:01 dmkorol

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.

cormacrelf avatar Feb 14 '19 03:02 cormacrelf

Example:

constructor(private dragulaService: DragulaService) { this.dragulaService.createGroup('VAMPIRES', { moves: () => true }); }

ngOnDestroy(): void { this.dragulaService.destroy('VAMPIRES'); }

sunzhengbo avatar Oct 22 '19 03:10 sunzhengbo