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

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

@ -16,6 +16,7 @@ namespace BlazorApp.Components
[Parameter] [Parameter]
public bool NoDrop { get; set; } public bool NoDrop { get; set; }
@ -44,6 +45,7 @@ namespace BlazorApp.Components
internal void OnDrop() internal void OnDrop()
{ {
if (NoDrop == true || Parent.CurrentDragItem == null) if (NoDrop == true || Parent.CurrentDragItem == null)
{ {
return; 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 }); 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 }); 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
2.0
2.0
2.0

Loading…
Cancel
Save