Closed amitapatiyal24 closed 3 years ago
We don't currently support drag&drop with virtual scrolling. Closing as a duplicate of https://github.com/angular/components/issues/10122.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
Reproduction
Use StackBlitz to reproduce your issue:
Steps to reproduce:
class="viewport ps blue-scrollbar member-box" [perfectScrollbar] (scrolledIndexChange)="nextBatch()" [cdkDropListData] = "selectedDimension?.memberSelections" (cdkDropListDropped)="onDrag($event)" [style.height]="memberHeight">
<li *cdkVirtualFor="let members of memberSelections " cdkDrag>{{member}}
public onDrag(event: CdkDragDrop<string[]>): void { if (event.previousContainer === event.container) { const PREV_IND_WITH_OFFSET: number = this.range ? this.range.start + event.previousIndex : event.previousIndex; const CUR_IND_WITH_OFFSET: number = this.range ? this.range.start + event.currentIndex : event.currentIndex ; moveItemInArray( this.selectedDimension.memberSelections, PREV_IND_WITH_OFFSET, CUR_IND_WITH_OFFSET); this.memberSelections = [...this.memberSelections]; } else { transferArrayItem(event.previousContainer.data, event.container.data, event.previousIndex, event.currentIndex); } this.val.emit(false); } public nextBatch(){ this.virtualForOf.viewChange.subscribe((range: ListRange) => this.range = range); console.log(this.range); }
Expected Behavior
What behavior were you expecting to see? list drag and drop for virtual scroll with a large dataset. e.g.(1000 of records)
Actual Behavior
What behavior did you actually see? I am using CDK virtual scroll and CDK drag/drop together for rendering the large list. When I am doing the drag and drop in the middle of the list, the dragged item is coming back to its original position. I have tried to solve this issue using the range, but still not able to get the expected result.
Environment
angular11