-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting [dragula] to null doesn't disable dragging #784
Comments
Hi @JosephSKh, I did this:
constructor(private dragulaService: DragulaService) {
dragulaService.setOptions('my-dragula-bag', {
moves: (el, source, handle, sibling) => !el.classList.contains('no-drag')
});
} |
@josiahaltschuler thank you for your reply, yes actually I've done this at last, but it just wasn't the solution I want to head to because of some requirements, I still need to fix this later , but thx man for your solution :) |
@JosephSKh No problem! |
Another (and probably cleaner) way of achieving the same is to provide two instances of the wrapper element, one with and one without dragula attributes, and move the content of the wrapper into an <div *ngIf="draggable"
[dragula]="bagName"
[dragulaModel]="collection">
<ng-container *ngTemplateOutlet="items"></ng-container>
</div>
<div *ngIf="!draggable">
<ng-container *ngTemplateOutlet="items"></ng-container>
</div>
<ng-template #items>
<ng-container *ngFor="let item of collection">
...
</ng-container>
</ng-template> |
In Angular4+, it should be possible to use <div *ngIf="draggable; else items" [dragula]="bagName" [dragulaModel]="collection">
<ng-container *ngTemplateOutlet="items"></ng-container>
</div>
<ng-template #items>
<ng-container *ngFor="let item of collection">
...
</ng-container>
</ng-template> |
Is that really cleaner though? Not really. HTML is the least clean part of Angular. Keep in in TS. But yes, there should be an easier way. Probably similar to the destruction logic in #794. |
In v2, you'll be able to just set [dragula] to null. Update: you can do that now. |
@renehamburger The solution you posted above, so does it make component draggable at run time ? |
this is something we can do, however it throws an error if dragulaModel is set
...
else if (changes && changes.dragulaModel) {
const { previousValue: prev, currentValue: current, firstChange } = changes.dragulaModel;
const { drake } = this.group;
... |
@AnthonyLenglet I get that it's not a proper solution, but it does circumvent the error; Also in my case the method reorderItems() was already needed for other operations. Not sur about your situation but it may help. |
For a newer version I have added it the following way :
|
I need to disable draggin in a certain state and setting [dragula] to null OR undefined doesn't do so
any ideas?
thx
The text was updated successfully, but these errors were encountered: