diff options
author | Emma@Rory& <root@rory.gay> | 2023-09-15 09:55:36 +0200 |
---|---|---|
committer | Emma@Rory& <root@rory.gay> | 2023-09-15 09:55:36 +0200 |
commit | e10fa389ce3c4d42deadfec8bf08c2fbb1a88d79 (patch) | |
tree | 1e2f8d8de07c6037ac4aa20be3b54ac43c2d7f2e /MatrixRoomUtils.Web/Shared/ModalWindow.razor | |
parent | Code cleanup (diff) | |
download | MatrixUtils-e10fa389ce3c4d42deadfec8bf08c2fbb1a88d79.tar.xz |
Refactors
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/ModalWindow.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/ModalWindow.razor | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor b/MatrixRoomUtils.Web/Shared/ModalWindow.razor deleted file mode 100644 index beb7198..0000000 --- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor +++ /dev/null @@ -1,86 +0,0 @@ -@using LibMatrix.Extensions -<div class="r-modal" style="top: @(_y)px; left: @(_x)px;"> - <div class="titlebar" @onmousedown="MouseDown" @onmouseup="MouseUp" @onmousemove="MouseMove" @onmouseleave="MouseMove"> - <b class="title" @ref="_titleRef">@Title</b> - <button class="btnclose" @onclick="OnCloseClicked">X</button> - <button class="btncollapse" @onclick="@(() => Collapsed = !Collapsed)">_</button> - </div> - <div class="r-modal-content" style="@((Collapsed ? "height: 0px;" : "") + $"min-width: {MinWidth}px;")"> - @ChildContent - </div> -</div> - -@code { - - [Parameter] - public RenderFragment? ChildContent { get; set; } - - [Parameter] - public string Title { get; set; } = "Untitled window"; - - [Parameter] - public double X { get; set; } = 60; - - [Parameter] - public double Y { get; set; } = 60; - - [Parameter] - public double MinWidth { get; set; } = 100; - - [Parameter] - public Action OnCloseClicked { get; set; } - - [Parameter] - public bool Collapsed { get; set; } = false; - - private ElementReference _titleRef; - - private double _x = 60; - private double _y = 60; - - protected override async Task OnInitializedAsync() { - _x = X; - _y = Y; - await base.OnInitializedAsync(); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) { - //set minwidth to title width - MinWidth = await JSRuntime.InvokeAsync<int>("getWidth", _titleRef) + 75; - await base.OnAfterRenderAsync(firstRender); - } - - private void WindowDrag(DragEventArgs obj) { - Console.WriteLine("Drag: " + obj.ToJson()); - - _x += obj.MovementX; - _y += obj.MovementY; - - StateHasChanged(); - } - - private bool isDragging = false; - private double dragX = 0; - private double dragY = 0; - - private void MouseDown(MouseEventArgs obj) { - isDragging = true; - dragX = obj.ClientX; - dragY = obj.ClientY; - } - - private void MouseUp(MouseEventArgs obj) { - isDragging = false; - } - - private void MouseMove(MouseEventArgs obj) { - if (!isDragging) return; - - _x += obj.ClientX - dragX; - _y += obj.ClientY - dragY; - dragX = obj.ClientX; - dragY = obj.ClientY; - StateHasChanged(); - } - -} |