ngx-dnd icon indicating copy to clipboard operation
ngx-dnd copied to clipboard

[question] How to cancel after drop event is emitted ?

Open marcio199226 opened this issue 5 years ago • 2 comments

I have a question once an element was dropped and I'm listening on drop event within ngxDroppable for displaying a confirm popup if container's of dragged element was changed. This popup has 2 buttons of course CANCEL | CONFIRM and when user clicks on cancel I would revert that dragged element and place it into it's initial container.

How can i achieve this ?

    <div class="list-cards ngx-dnd-container" [id]="layer1.id" ngxDroppable="card" (drop)="onDrop($event)">
      <custom-element [id]="layer1.id" ngxDraggable class="ngx-dnd-item"
        *ngFor="let layer0 of layer1.layers0" [model]="layer1">
      </custom-element>
    </div>

I saw that already exists an issue #5 but there are no workarounds or pull requests until now.

Can you provide some solution?

marcio199226 avatar Jul 02 '19 09:07 marcio199226

Ok i have fixed it by relying on angular's dom patching through trackBy and playing with my collection instead of relaying on dragula's dom manipulation which moves or removes nodes based on dnd events

marcio199226 avatar Jul 03 '19 09:07 marcio199226

hi,

by any chance, do you still have that solution and can share or explain it more?

Thanks

musman013 avatar Aug 09 '21 10:08 musman013