master
Lucas Delanier 2 years ago
parent 4192e934ce
commit 8cc5fcf500

@ -5,7 +5,8 @@
@ondragstart="@OnDragStart"
@ondrop="@OnDrop"
@ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave">
@ondragleave="@OnDragLeave"
@ondragend="@OnDragEnd">
@if (Item != null)
{

@ -16,6 +16,7 @@ namespace BlazorApp.Components
[Parameter]
public bool NoDrop { get; set; }
@ -44,6 +45,7 @@ namespace BlazorApp.Components
internal void OnDrop()
{
if (NoDrop == true || Parent.CurrentDragItem == null)
{
return;
@ -58,12 +60,6 @@ namespace BlazorApp.Components
}
}
else if (this.Item.Id != Parent.CurrentDragItem.Id)
{
Item temp = ItemFactory.Create(this.Item);
this.Item = ItemFactory.Create(Parent.CurrentDragItem);
Parent.CurrentDragItem = ItemFactory.Create(temp);
}
Parent.Actions.Add(new InventoryAction { Action = "Drop", Item = this.Item, Index = this.Index });
@ -78,5 +74,14 @@ namespace BlazorApp.Components
Parent.Actions.Add(new InventoryAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
}
private void OnDragEnd()
{
if (Parent.Actions.Last().Action == "Drag Leave")
{
this.Item = null;
}
Parent.Actions.Add(new InventoryAction { Action = "Delete", Item = this.Item, Index = this.Index });
}
}
}

@ -154,3 +154,12 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

Loading…
Cancel
Save