swimlane / ngx-dnd

🕶 Drag, Drop and Sorting Library for Angular2 and beyond!
https://swimlane.github.io/ngx-dnd/
MIT License
575 stars 135 forks source link

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

Open marcio199226 opened 5 years ago

marcio199226 commented 5 years ago

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 commented 5 years ago

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

musman013 commented 3 years ago

hi,

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

Thanks