mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-12 11:55:24 +08:00
9739cd4161
* fix: unexpected behavior of Drawer(#1749) 1. The scroll bar of the body is enabled after closing one of the multiple drawers 2. Bad parameter NoAnimation. * chore: remove debug output * chore: add comments for ComponentStatus * fix: different behaviors in WASM and Server modes * chore: remove debug output
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class DrawerContainer
|
|
{
|
|
[Inject]
|
|
private DrawerService DrawerService { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
DrawerService.OnCloseEvent += DrawerService_OnClose;
|
|
DrawerService.OnOpenEvent += DrawerService_OnCreate;
|
|
DrawerService.OnUpdateEvent += DrawerService_OnUpdateEvent;
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
DrawerService.OnCloseEvent -= DrawerService_OnClose;
|
|
DrawerService.OnOpenEvent -= DrawerService_OnCreate;
|
|
DrawerService.OnUpdateEvent -= DrawerService_OnUpdateEvent;
|
|
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private readonly List<DrawerRef> _drawerRefs = new List<DrawerRef>();
|
|
|
|
/// <summary>
|
|
/// Create and Open a drawer
|
|
/// </summary>
|
|
private async Task DrawerService_OnCreate(DrawerRef drawerRef)
|
|
{
|
|
if (!_drawerRefs.Contains(drawerRef))
|
|
{
|
|
_drawerRefs.Add(drawerRef);
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(10);
|
|
}
|
|
drawerRef.Config.Visible = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update drawer
|
|
/// </summary>
|
|
/// <param name="drawerRef"></param>
|
|
/// <returns></returns>
|
|
private async Task DrawerService_OnUpdateEvent(DrawerRef drawerRef)
|
|
{
|
|
if (_drawerRefs.Contains(drawerRef))
|
|
{
|
|
await InvokeStateHasChangedAsync();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Close the drawer
|
|
/// </summary>
|
|
private async Task DrawerService_OnClose(DrawerRef drawerRef)
|
|
{
|
|
if (drawerRef.Config.Visible)
|
|
{
|
|
drawerRef.Config.Visible = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(300);
|
|
if (_drawerRefs.Contains(drawerRef))
|
|
{
|
|
_drawerRefs.Remove(drawerRef);
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
}
|
|
}
|