Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CDK Drag and Drop: Cancel drag-action

With the new drag and drop feature of the @angular/cdk (I'm currently using version 7.0.0-beta.2), is it possible to cancel a drag-action?

I did not find a matching function on 'CdkDrag' which could do the trick.

Edit from 2019-01-10

Thanks for the responses so far. I guess I wasn't clear enough, though: I'm looking for a way to cancel a drag-action which is already in progress. I. e. while dragging an item, I want to have the possibility to make that item return to the container where it comes from (e. g. by pressing the Escape key).

Any ideas?

like image 700
Johannes Heucher Avatar asked Oct 02 '18 12:10

Johannes Heucher


1 Answers

it's not possible with anguar 7.0.0, you have to update to angular 7.1.0, then you have:

[cdkDragDisabled]="condition"

which works perfect!

like image 165
cucuru Avatar answered Oct 05 '22 14:10

cucuru