implemented drag&drop for UserCollectionEntryGrid
This commit is contained in:
1 parent
5f0c56239f
commit
c8578ccf77
2 files changed
+24
-3
No files matched your search
+4
-3
@@ -1,4 +1,5 @@
|
||||
<div class="movies-container">
|
||||
<app-list-entry-card *ngFor="let entry of entries" [entry]="entry" [listId]="listId"
|
||||
(refrechEvent)="refrechEventReceiver()"></app-list-entry-card>
|
||||
<div class="movies-container" cdkDropList [cdkDropListData]="entries" (cdkDropListDropped)="drop($any($event))">
|
||||
<app-list-entry-card cdkDrag *ngFor="let entry of entries" [entry]="entry" [listId]="listId"
|
||||
(refrechEvent)="refrechEventReceiver()">
|
||||
</app-list-entry-card>
|
||||
</div>
|
||||
+20
@@ -1,5 +1,11 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
CdkDragStart,
|
||||
moveItemInArray,
|
||||
} from '@angular/cdk/drag-drop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-collection-entry-grid',
|
||||
@@ -13,4 +19,18 @@ export class UserCollectionEntryGridComponent {
|
||||
refrechEventReceiver() {
|
||||
console.log('event recieved');
|
||||
}
|
||||
|
||||
drop(event: CdkDragDrop<any[]>) {
|
||||
moveItemInArray(this.entries, event.previousIndex, event.currentIndex);
|
||||
}
|
||||
|
||||
dragStart(event: CdkDragStart): void {
|
||||
event.source.element.nativeElement.classList.add('custom-dragging-class');
|
||||
}
|
||||
|
||||
dragEnd(event: CdkDragEnd): void {
|
||||
event.source.element.nativeElement.classList.remove(
|
||||
'custom-dragging-class'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user