From 816f59ec0a260db00dd3d6b1835cfcc2f4700a7c Mon Sep 17 00:00:00 2001 From: jian Date: Thu, 23 Nov 2023 14:34:38 +0800 Subject: [PATCH] =?UTF-8?q?BI-134635=20fix:=20=E7=A9=BA=E7=99=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E9=AB=98=E5=BA=A6=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fineui/src/base/list/virtualgrouplist.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/fineui/src/base/list/virtualgrouplist.js b/packages/fineui/src/base/list/virtualgrouplist.js index e2e0d5ddf..bdccaed3d 100644 --- a/packages/fineui/src/base/list/virtualgrouplist.js +++ b/packages/fineui/src/base/list/virtualgrouplist.js @@ -26,6 +26,7 @@ export class VirtualGroupList extends Widget { init() { this.renderedIndex = -1; + this._initSummaryHeight(); } static xtype = "bi.virtual_group_list"; @@ -44,7 +45,7 @@ export class VirtualGroupList extends Widget { }, { type: VirtualGroup.xtype, - height: rowHeight * items.length, + height: this.summaryHeight, ref: (ref) => { this.container = ref; }, @@ -83,8 +84,10 @@ export class VirtualGroupList extends Widget { o.scrollTop = this.element.scrollTop(); if (!this.ticking) { requestAnimationFrame(() => { + const start = new Date().getTime(); this._calculateBlocksToRender(); this.ticking = false; + console.log(new Date().getTime() - start); }); this.ticking = true; } @@ -200,16 +203,21 @@ export class VirtualGroupList extends Widget { _restore() { const o = this.options; this.renderedIndex = -1; - if (isFunction(o.rowHeight)) { - this.summaryHeight = sum(o.items, o.rowHeight); - } else { - this.summaryHeight = this._isAutoHeight() ? 0 : o.rowHeight * o.items.length; - } + this._initSummaryHeight(); // 依赖于cache的占位元素也要初始化 this.topBlank.setHeight(0); this.bottomBlank.setHeight(0); } + _initSummaryHeight() { + const { rowHeight, items } = this.options; + if (isFunction(rowHeight)) { + this.summaryHeight = sum(items, rowHeight); + } else { + this.summaryHeight = this._isAutoHeight() ? 0 : rowHeight * items.length; + } + } + // 暂时只支持固定行高的场景 scrollTo(scrollTop) { this.options.scrollTop = scrollTop;