Skip to content

Commit

Permalink
feat: add async in scenegraph.updateContainer()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Mar 12, 2024
1 parent 9fcb074 commit 85c4edd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/vtable/src/scenegraph/layout/compute-col-width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
34 changes: 22 additions & 12 deletions packages/vtable/src/scenegraph/scenegraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export class Scenegraph {
// this.updateContainerWidth(col, detaX);
if (!skipUpdateContainer) {
// this.updateContainerAttrWidthAndX();
this.updateContainer();
this.updateContainer(true);
}
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 85c4edd

Please sign in to comment.