My drag drop code is working fine with mouse, but not on a touch screen. Should the below work or is there a mistake here?
The draggable item:
<div class="draggable-area" draggable="true"
@ondragstart="@(() => HandleDragStart())"
@ontouchstart="@(() => HandleDragStart())">
protected async virtual Task HandleDragStart()
{
// set the draggable object
_draggableItem = this;
}
The droppable area (in a different component):
<div class="droppable-area"
@ondrop="HandleDrop"
@ondrop:stopPropagation="true"
ondragover="event.preventDefault();">
protected async override Task HandleDrop()
{
// handle the drop
Console.WriteLine($"Dropped item: {_draggableItem}");
}