Browse Source

BI-134635 fix: 空白问题,高度初始化

research/test
jian 1 year ago
parent
commit
816f59ec0a
  1. 20
      packages/fineui/src/base/list/virtualgrouplist.js

20
packages/fineui/src/base/list/virtualgrouplist.js

@ -26,6 +26,7 @@ export class VirtualGroupList extends Widget {
init() { init() {
this.renderedIndex = -1; this.renderedIndex = -1;
this._initSummaryHeight();
} }
static xtype = "bi.virtual_group_list"; static xtype = "bi.virtual_group_list";
@ -44,7 +45,7 @@ export class VirtualGroupList extends Widget {
}, },
{ {
type: VirtualGroup.xtype, type: VirtualGroup.xtype,
height: rowHeight * items.length, height: this.summaryHeight,
ref: (ref) => { ref: (ref) => {
this.container = ref; this.container = ref;
}, },
@ -83,8 +84,10 @@ export class VirtualGroupList extends Widget {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
if (!this.ticking) { if (!this.ticking) {
requestAnimationFrame(() => { requestAnimationFrame(() => {
const start = new Date().getTime();
this._calculateBlocksToRender(); this._calculateBlocksToRender();
this.ticking = false; this.ticking = false;
console.log(new Date().getTime() - start);
}); });
this.ticking = true; this.ticking = true;
} }
@ -200,16 +203,21 @@ export class VirtualGroupList extends Widget {
_restore() { _restore() {
const o = this.options; const o = this.options;
this.renderedIndex = -1; this.renderedIndex = -1;
if (isFunction(o.rowHeight)) { this._initSummaryHeight();
this.summaryHeight = sum(o.items, o.rowHeight);
} else {
this.summaryHeight = this._isAutoHeight() ? 0 : o.rowHeight * o.items.length;
}
// 依赖于cache的占位元素也要初始化 // 依赖于cache的占位元素也要初始化
this.topBlank.setHeight(0); this.topBlank.setHeight(0);
this.bottomBlank.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) { scrollTo(scrollTop) {
this.options.scrollTop = scrollTop; this.options.scrollTop = scrollTop;

Loading…
Cancel
Save