From d4d0342dacf7a1a72b4055a9d32df23f48cefe84 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 9 Dec 2022 03:08:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20drawer=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Drawer/Drawer.js | 21 --------------- .../wwwroot/bundle/bootstrap.blazor.js | 22 --------------- .../wwwroot/js/bootstrap.blazor.bundle.js | 22 --------------- src/BootstrapBlazor/wwwroot/modules/drawer.js | 27 +++++++++++++++++++ 4 files changed, 27 insertions(+), 65 deletions(-) delete mode 100644 src/BootstrapBlazor/Components/Drawer/Drawer.js create mode 100644 src/BootstrapBlazor/wwwroot/modules/drawer.js diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.js b/src/BootstrapBlazor/Components/Drawer/Drawer.js deleted file mode 100644 index f06b0ef1a..000000000 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.js +++ /dev/null @@ -1,21 +0,0 @@ -(function ($) { - $.extend({ - bb_drawer: function (el, open) { - var $el = $(el); - if (open) { - $el.addClass('is-open'); - $('body').addClass('overflow-hidden'); - } - else { - if ($el.hasClass('is-open')) { - $el.removeClass('is-open').addClass('is-close'); - var handler = window.setTimeout(function () { - window.clearTimeout(handler); - $el.removeClass('is-close'); - $('body').removeClass('overflow-hidden'); - }, 350); - } - } - } - }); -})(jQuery); diff --git a/src/BootstrapBlazor/wwwroot/bundle/bootstrap.blazor.js b/src/BootstrapBlazor/wwwroot/bundle/bootstrap.blazor.js index 06670f4e3..a7a5d4351 100644 --- a/src/BootstrapBlazor/wwwroot/bundle/bootstrap.blazor.js +++ b/src/BootstrapBlazor/wwwroot/bundle/bootstrap.blazor.js @@ -1292,28 +1292,6 @@ }); })(jQuery); -(function ($) { - $.extend({ - bb_drawer: function (el, open) { - var $el = $(el); - if (open) { - $el.addClass('is-open'); - $('body').addClass('overflow-hidden'); - } - else { - if ($el.hasClass('is-open')) { - $el.removeClass('is-open').addClass('is-close'); - var handler = window.setTimeout(function () { - window.clearTimeout(handler); - $el.removeClass('is-close'); - $('body').removeClass('overflow-hidden'); - }, 350); - } - } - } - }); -})(jQuery); - (function ($) { Number.prototype.toRadians = function () { return this * Math.PI / 180; diff --git a/src/BootstrapBlazor/wwwroot/js/bootstrap.blazor.bundle.js b/src/BootstrapBlazor/wwwroot/js/bootstrap.blazor.bundle.js index 0558e46ba..b025d7e4a 100644 --- a/src/BootstrapBlazor/wwwroot/js/bootstrap.blazor.bundle.js +++ b/src/BootstrapBlazor/wwwroot/js/bootstrap.blazor.bundle.js @@ -19241,28 +19241,6 @@ return jQuery; }); })(jQuery); -(function ($) { - $.extend({ - bb_drawer: function (el, open) { - var $el = $(el); - if (open) { - $el.addClass('is-open'); - $('body').addClass('overflow-hidden'); - } - else { - if ($el.hasClass('is-open')) { - $el.removeClass('is-open').addClass('is-close'); - var handler = window.setTimeout(function () { - window.clearTimeout(handler); - $el.removeClass('is-close'); - $('body').removeClass('overflow-hidden'); - }, 350); - } - } - } - }); -})(jQuery); - (function ($) { Number.prototype.toRadians = function () { return this * Math.PI / 180; diff --git a/src/BootstrapBlazor/wwwroot/modules/drawer.js b/src/BootstrapBlazor/wwwroot/modules/drawer.js new file mode 100644 index 000000000..e295272a7 --- /dev/null +++ b/src/BootstrapBlazor/wwwroot/modules/drawer.js @@ -0,0 +1,27 @@ +import BlazorComponent from "./base/blazor-component.js" + +export class Drawer extends BlazorComponent { + _init() { + this._body = document.querySelector('body') + } + + _execute(args) { + const open = args[0] + if (open) { + this._element.classList.add('is-open') + this._body.classList.add('overflow-hidden') + } + else { + if (this._element.classList.contains('is-open')) { + this._element.classList.remove('is-open') + this._element.classList.add('is-close') + let handler = window.setTimeout(() => { + window.clearTimeout(handler) + handler = null + this._element.classList.remove('is-close') + this._body.classList.remove('overflow-hidden') + }, 350) + } + } + } +} -- Gitee From 33e0d1df0f4c4f56dd7eaf04f96bb8820146d983 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 9 Dec 2022 03:08:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=8A=BD=E5=B1=89=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E8=84=9A=E6=9C=AC=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Drawer/Drawer.razor | 10 +++++----- .../Components/Drawer/Drawer.razor.cs | 16 ++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor b/src/BootstrapBlazor/Components/Drawer/Drawer.razor index ca493537f..be9d084d3 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor @@ -1,10 +1,10 @@ @namespace BootstrapBlazor.Components -@inherits BootstrapComponentBase +@inherits BootstrapModuleComponentBase -
-
- diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs index 030faa4ea..f3cf4c2b1 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs @@ -7,7 +7,8 @@ namespace BootstrapBlazor.Components; /// /// Drawer 组件基类 /// -public sealed partial class Drawer +[JSModuleAutoLoader] +public partial class Drawer { private ElementReference DrawerElement { get; set; } @@ -85,19 +86,10 @@ public sealed partial class Drawer public RenderFragment? ChildContent { get; set; } /// - /// OnAfterRenderAsync 方法 + /// /// - /// /// - protected override async Task OnAfterRenderAsync(bool firstRender) - { - await base.OnAfterRenderAsync(firstRender); - - if (!firstRender) - { - await JSRuntime.InvokeVoidAsync(DrawerElement, "bb_drawer", IsOpen); - } - } + protected override Task ModuleExecuteAsync() => InvokeExecuteAsync(Id, IsOpen); /// /// 点击背景遮罩方法 -- Gitee From 7c171ad3c5317b28ffc107f2f118dabef67b2db8 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 9 Dec 2022 03:24:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=8A=BD=E5=B1=89=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Drawer/Drawer.razor | 4 +++- .../Components/Drawer/Drawer.razor.cs | 20 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor b/src/BootstrapBlazor/Components/Drawer/Drawer.razor index be9d084d3..1e4b6cdc2 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor @@ -4,7 +4,9 @@
- @ChildContent + + @ChildContent +
diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs index f3cf4c2b1..683444a95 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs @@ -98,9 +98,25 @@ public partial class Drawer { if (IsBackdrop) { - IsOpen = false; - if (IsOpenChanged.HasDelegate) await IsOpenChanged.InvokeAsync(IsOpen); + await Close(); if (OnClickBackdrop != null) await OnClickBackdrop.Invoke(); } } + + /// + /// 关闭抽屉方法 + /// + /// + public async Task Close() + { + IsOpen = false; + if (IsOpenChanged.HasDelegate) + { + await IsOpenChanged.InvokeAsync(IsOpen); + } + else + { + StateHasChanged(); + } + } } -- Gitee From c55b2443f0e80f5d45dbdacf9ddf63353fe99da4 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 9 Dec 2022 03:25:14 +0800 Subject: [PATCH 4/4] chore: bump version 7.1.4 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 05b381327..e0f2bbf85 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 7.1.4-beta02 + 7.1.4 -- Gitee