From 85c4edde8ed02074edb14e0b9529cea60b0cbef1 Mon Sep 17 00:00:00 2001 From: Rui-Sun Date: Tue, 12 Mar 2024 17:18:17 +0800 Subject: [PATCH] feat: add async in scenegraph.updateContainer() --- .../scenegraph/layout/compute-col-width.ts | 2 +- packages/vtable/src/scenegraph/scenegraph.ts | 34 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/packages/vtable/src/scenegraph/layout/compute-col-width.ts b/packages/vtable/src/scenegraph/layout/compute-col-width.ts index 7117c9821..1344c01b6 100644 --- a/packages/vtable/src/scenegraph/layout/compute-col-width.ts +++ b/packages/vtable/src/scenegraph/layout/compute-col-width.ts @@ -202,7 +202,7 @@ export function computeColsWidth(table: BaseTableAPI, colStart?: number, colEnd? table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true, true); } } - table.scenegraph.updateContainer(); + table.scenegraph.updateContainer(true); } // console.log('computeColsWidth time:', (typeof window !== 'undefined' ? window.performance.now() : 0) - time, colStart, colEnd); } diff --git a/packages/vtable/src/scenegraph/scenegraph.ts b/packages/vtable/src/scenegraph/scenegraph.ts index 3849be910..e0c3d466c 100644 --- a/packages/vtable/src/scenegraph/scenegraph.ts +++ b/packages/vtable/src/scenegraph/scenegraph.ts @@ -708,7 +708,7 @@ export class Scenegraph { // this.updateContainerWidth(col, detaX); if (!skipUpdateContainer) { // this.updateContainerAttrWidthAndX(); - this.updateContainer(); + this.updateContainer(true); } } @@ -1479,21 +1479,31 @@ export class Scenegraph { this.bodyGroup.setAttribute('x', this.rowHeaderGroup.attribute.width); } - updateContainer() { - if (!this._needUpdateContainer) { - this._needUpdateContainer = true; - setTimeout(() => { - this.updateContainerAttrWidthAndX(); + updateContainer(async: boolean = false) { + if (async) { + if (!this._needUpdateContainer) { + this._needUpdateContainer = true; + setTimeout(() => { + this.updateContainerAttrWidthAndX(); - this.updateTableSize(); + this.updateTableSize(); - this.component.updateScrollBar(); - this.updateNextFrame(); + this.component.updateScrollBar(); + this.updateNextFrame(); - this._needUpdateContainer = false; - }, 0); + this._needUpdateContainer = false; + }, 0); + } + } else { + this.updateContainerAttrWidthAndX(); + + this.updateTableSize(); + + this.component.updateScrollBar(); + this.updateNextFrame(); + + this._needUpdateContainer = false; } - // console.trace('updateContainer'); } updateCellContentWhileResize(col: number, row: number) {