我正在尝试实现ngx-virtual-scroll和ng2-dragula 一起
这是我当前的Stackblitz更新:Stackblitz
问题如下:
<virtual-scroller #scroll2 [id]="myGroupId" [dragula]="myGroupId" [(dragulaModel)]="myList.list2" [items]="myList.list2" class="virtual-scroller">
<div class="virtual-scroller-element" *ngFor="let card of myList.list2; let i = index ">{{myList.list2[i]}}</div>
</virtual-scroller>
要使Dragula正常工作,组声明[dragula]="myGroupId"
与要拖动的项目之间必须没有HTML。
但是几乎所有虚拟滚动器库(包括该库)都在div中创建了项。由软件包自动生成。因此,我的整个div将被拖动。
我想知道您是否有任何调整使其起作用?
答案 0 :(得分:1)
我以前从未使用过它,但这似乎可以解决问题(我不了解视觉效果,我猜可以对其进行调整,但是在功能上可以使用)。请测试:
<div class="virtual-scroller-container">
<div class="virtual-scroller-column">
<virtual-scroller #scroll1 [id]="myGroupId" [items]="myList.list1" class="virtual-scroller">
<div class='container' [dragula]="myGroupId" [(dragulaModel)]="myList.list1">
<div class="virtual-scroller-element" *ngFor="let card of myList.list1; let i = index ">{{myList.list1[i]}}</div>
</div>
</virtual-scroller>
</div>
<div class="virtual-scroller-column">
<virtual-scroller #scroll2 [id]="myGroupId" class="virtual-scroller">
<div class='container' [dragula]="myGroupId" [(dragulaModel)]="myList.list2">
<div class="virtual-scroller-element" *ngFor="let card of myList.list2; let i = index ">{{myList.list2[i]}}</div>
</div>
</virtual-scroller>
</div>
<div class="virtual-scroller-column">
<virtual-scroller #scroll3 [id]="myGroupId" [items]="myList.list3" class="virtual-scroller">
<div class='container' [dragula]="myGroupId" [(dragulaModel)]="myList.list3">
<div class="virtual-scroller-element" *ngFor="let card of myList.list3; let i = index ">{{myList.list3[i]}}</div>
</div>
</virtual-scroller>
</div>
</div>