Jędrek Markowski
Jędrek Markowski

Reputation: 444

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

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.

Upvotes: 3

Views: 1339

Answers (1)

Norbert Bartko
Norbert Bartko

Reputation: 2632

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

Upvotes: 1

Related Questions