I tried to change the height of the dragged object using angular material drag and drop. I have tried to change the class name of the dragged div using cdkdragstart event and adjusted the height in the css.
app.component.html
<div cdkDropList #nameDragDrop="cdkDropList" [cdkDropListData]="names" [cdkDropListConnectedTo]="['nameTime']" (cdkDropListDropped)="drop($event)">
<div *ngFor="let iteration = index" cdkDrag (cdkDragMoved)="dragStarted($event,iteration)" (cdkDragEnded)="dragEnded(iteration)">
<div class="nameDiv" [ngClass]="{'reduceHeight': hideImageIcon === iteration, 'scenes': hideImageIcon !== iteration }">
</div>
</div>
</div
app.component.ts
dragStarted(event,index:any) {
this.hideImageIcon = index;
}
drop(event: CdkDragDrop<String[]>) {
if (event.previousContainer.id === event.container.id) {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
} else {
transferArrayItem(event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex);
}
}
I tried to get the dragged index using drag started method and assigned the index to the variable and change the class name in html file based on the condition.
app.component.css
.reduceHeight{
height:27px!important;
}
.show{
display: block!important;
}
.hide{
display: none!important;
}
Here the problem is, height is not getting changed while dropping the item. I want to change the height of the dragged object on start of the drag event. Is there any event is available in angular material drag and drop to change the height of the dragged object?