From 12e7b9b1419edc05a7e8918148f8a6484bcca536 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 5 Jul 2022 17:24:15 +0800 Subject: [PATCH] =?UTF-8?q?DESIGN-4216=20feat:=20=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=8F=90=E4=BE=9B=E4=B8=80=E4=BA=9B=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/list/virtualgrouplist.js | 13 ++++++++++--- typescript/base/list/virtualgrouplist.ts | 11 +++++++++++ typescript/index.ts | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 typescript/base/list/virtualgrouplist.ts diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index 0eae74875..cb8d1b533 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -62,7 +62,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { }) : o.items; this._populate(); this.ticking = false; - this.element.scroll(function() { + this.element.scroll(function () { o.scrollTop = self.element.scrollTop(); if (!self.ticking) { requestAnimationFrame(function () { @@ -123,7 +123,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { } this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex))); this.container.populate(items.map(function (item, i) { - return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i) + return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i); })); } else { for (var i = (start < 0 ? 0 : start); i <= end; i++) { @@ -134,7 +134,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { } this.container.element.height(o.rowHeight * o.items.length - topHeight); this.container.populate(items.map(function (item, i) { - return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i) + return o.itemFormatter(item, (start < 0 ? 0 : start) * o.blockSize + i); })); } }, @@ -162,6 +162,13 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { this.bottomBlank.setHeight(0); }, + // 暂时只支持固定行高的场景 + scrollTo: function (scrollTop) { + this.options.scrollTop = scrollTop; + this._calculateBlocksToRender(); + this.element.scrollTop(scrollTop); + }, + restore: function () { this.options.scrollTop = 0; this._restore(); diff --git a/typescript/base/list/virtualgrouplist.ts b/typescript/base/list/virtualgrouplist.ts new file mode 100644 index 000000000..51b27423d --- /dev/null +++ b/typescript/base/list/virtualgrouplist.ts @@ -0,0 +1,11 @@ +import { Widget } from "../../core/widget"; + +export declare class VirtualGroupList extends Widget { + static xtype: string; + + restore(): void; + + populate(items: T[]): void; + + scrollTo(scrollTop: number): void; +} diff --git a/typescript/index.ts b/typescript/index.ts index d0d524c36..3aaca1ead 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -157,6 +157,7 @@ import { EditorIconCheckCombo } from "./case/combo/editoriconcheckcombo/combo.ed import { IconTextValueCombo } from "./case/combo/icontextvaluecombo/combo.icontextvalue"; import { ListView } from "./base/list/listview"; import { VirtualList } from "./base/list/virtuallist"; +import { VirtualGroupList } from "./base/list/virtualgrouplist"; import { FloatCenterLayout } from "./core/wrapper/layout/middle/middle.float.center"; import { _msg } from "./base/foundation/message"; import { _web } from "./core/platform/web"; @@ -361,6 +362,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { IconTextValueCombo: typeof IconTextValueCombo; ListView: typeof ListView; VirtualList: typeof VirtualList; + VirtualGroupList: typeof VirtualGroupList; FloatCenterLayout: typeof FloatCenterLayout; Msg: _msg; DynamicYearMonthPopup: typeof DynamicYearMonthPopup; @@ -556,6 +558,7 @@ export { IconTextValueCombo, ListView, VirtualList, + VirtualGroupList, FloatCenterLayout, DynamicYearMonthPopup, DateCalendarPopup,