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() {
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;

Loading…
Cancel
Save