【发布时间】:2020-06-01 19:58:09
【问题描述】:
我开发了一个滑块,向我展示了几张图片。
在顶部(大图像和滑块所在的位置)我将初始图像作为主图像。
在底部我有辅助图像(见下图)。
有没有办法将图像拖动到包含滑块的 div 以更改顺序?基本上我打算将小框中的图像与大框中的第一张图像交换。
我也可以横向更改小图像的顺序吗?
谢谢。
代码
<div class="col-md-6" style="overflow-y: auto;" (cdkDropListDropped)="drop($event)">
<div class="drop" [style.border-width.px]="imagens.length > 0 ? 0: 3">
<div class="abc">
<ngb-carousel style="outline: none;" id="carousel" #carousel *ngIf="imagens" (slide)="change($event)">
<ng-template *ngFor="let imgIdx of imagens; let i = index" [id]="i" ngbSlide>
<div class="picsum-img-wrapper">
<img [src]="imgIdx.Imagem" style="border-radius: 8px;" class="img-responsive Images">
</div>
</ng-template>
</ngb-carousel>
</div>
</div>
<div class="row">
<div class="Upcard" *ngFor="let imgIdx of imagens | slice:1" >
<img class="img-responsive" [src]="imgIdx.Imagem" style="width: 100%; height: 100%">
</div>
</div>
</div>
我尝试使用这个,在 html cdkdrag 中添加,但是没有,它不起作用。
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.imagens, event.previousIndex, event.currentIndex);
}
dropBig(event: CdkDragDrop<string[]>) {
moveItemInArray(this.imagens, event.previousIndex, 0);
}
【问题讨论】:
标签: angular typescript drag-and-drop draggable angular-cdk