Angular CDK's Drag&Drop, keep order until drop

Viewed 837

I'm trying to find out, if it's possible using CDK's Drag&Drop to not change position of any element form the list(during dragging) until it's dropped. Right now elements change their position when any element is dragged.

1 Answers

You can use the cdkDropListSortingDisabled directive.

<div
    cdkDropList
    [cdkDropListData]="items"
    class="example-list"
    cdkDropListSortingDisabled
    (cdkDropListDropped)="drop($event)">
    <div class="example-box" *ngFor="let item of items" cdkDrag>{{item}}</div>
</div>

For further examples see cdk drag and drop examples

Related