Skip to content

Commit

Permalink
Two zones "freeze" issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Tarasevich committed Aug 12, 2020
1 parent 84123f6 commit 489d7b1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions Plk.Blazor.DragDrop.Demo/Data/TodoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class TodoItem
{
public string Titel { get; set; }
public bool IsDone { get; set; }
public bool IsFocused { get; set; }
}
}
49 changes: 36 additions & 13 deletions Plk.Blazor.DragDrop.Demo/Pages/TwoZones.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@

<div class="bg-light">First Dropzone:</div>

<Dropzone Items="MyFirstList" TItem="TodoItem" OnItemDrop="@((i)=>lastdropped = i)">
<div class="mt-2" style="border: 2px solid blue">
@context.Titel
</div>
</Dropzone>
<Dropzone Items="MyFirstList" TItem="TodoItem" OnItemDrop="@((i)=>lastdropped = i)">
@{
string dragClass = context.IsFocused
? "mt-2__focused"
: "mt-2";
}
<div class="@dragClass" @onclick="() => SetFocus(context)">
@context.Titel
</div>
</Dropzone>

<hr />

<div class="bg-light">Second Dropzone:</div>

<Dropzone Items="MySecondList" TItem="TodoItem" OnItemDrop="@((i)=>lastdropped = i)">
<div class="mt-2" style="border: 2px solid black">
@context.Titel
</div>
</Dropzone>
<Dropzone Items="MySecondList" TItem="TodoItem" OnItemDrop="@((i)=>lastdropped = i)">
@{
string dragClass = context.IsFocused
? "mt-2__focused"
: "mt-2";
}
<div class="@dragClass">
@context.Titel
</div>
</Dropzone>

<hr />

Expand All @@ -34,7 +44,7 @@
private TodoItem lastdropped { get; set; }

public List<TodoItem> MyFirstList = new List<TodoItem>()
{
{
new TodoItem(){Titel = "Item 1"},
new TodoItem(){Titel = "Item 2"},
new TodoItem(){Titel = "Item 3"},
Expand All @@ -43,12 +53,25 @@
};

public List<TodoItem> MySecondList = new List<TodoItem>()
{
{
new TodoItem(){Titel = "Item 6"},
new TodoItem(){Titel = "Item 7"},
new TodoItem(){Titel = "Item 8"},
new TodoItem(){Titel = "Item 9"},
new TodoItem(){Titel = "Item 10"},
};

}
TodoItem FocusedComponent { get; set; }

private void SetFocus(TodoItem item)
{
if (FocusedComponent != null)
{
FocusedComponent.IsFocused = false;

FocusedComponent = null;
}
item.IsFocused = true;
FocusedComponent = item;
}
}
4 changes: 3 additions & 1 deletion Plk.Blazor.DragDrop.Demo/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ app {
min-height: 50px;
}


.mt-2__focused{
border:3px solid red;
}

.grid-container {
display: grid;
Expand Down

0 comments on commit 489d7b1

Please sign in to comment.