From d7ff39839151faf6f1ab7f66a4f2aeff35034e27 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 14:46:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.js | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index fba8039ed26..1aafd4dbea9 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -51,6 +51,7 @@ export function reset(id) { const shim = [...table.el.children].find(i => i.classList.contains('table-shim')) if (shim !== void 0) { + table.shim = shim; table.thead = [...shim.children].find(i => i.classList.contains('table-fixed-header')) table.isResizeColumn = shim.classList.contains('table-resize') if (table.thead) { @@ -102,13 +103,23 @@ export function reset(id) { table.pages = [...table.el.children].find(i => i.classList.contains('nav-pages')); - setBodyHeight(table) setColumnToolboxListener(table); + if (isVisible(table.el) === false) { + table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); + return; + } + + observeHeight(table) +} + +const observeHeight = table => { + setBodyHeight(table); + const observer = new ResizeObserver(entries => { entries.forEach(entry => { - if (entry.target === shim) { + if (entry.target === table.shim) { setTableDefaultWidth(table); } else if (entry.target === table.search || entry.target === table.toolbar || entry.target === table.pages) { @@ -117,7 +128,7 @@ export function reset(id) { }); }); if (table.thead) { - observer.observe(shim); + observer.observe(table.shim); } if (table.search) { observer.observe(table.search); @@ -280,18 +291,16 @@ const check = table => { table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); } else { - delete table.loopCheckHeightHandler; - setBodyHeight(table); + if (table.loopCheckHeightHandler > 0) { + cancelAnimationFrame(table.loopCheckHeightHandler); + delete table.loopCheckHeightHandler; + } + observeHeight(table); } }; const setBodyHeight = table => { const el = table.el - if (isVisible(el) === false) { - table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); - return; - } - const children = [...el.children] const search = children.find(i => i.classList.contains('table-search')) table.search = search; From 4cb0b109bcc9ee3f030f2e7f96a7f7f8ffd12a32 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 18 Dec 2024 14:50:01 +0800 Subject: [PATCH 2/2] chore: bump version 9.1.6-beta01 --- 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 ab1fc6df3fa..1cc7f87b6bd 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.5 + 9.1.6-beta01