Add LazyListView.onRangeVisible optional callback

Will be used in sync v3 to request different parts of the room list.
This commit is contained in:
Kegan Dougal 2021-11-23 11:16:09 +00:00
parent c6c0fb93fb
commit 63b3c6c909
2 changed files with 8 additions and 1 deletions

View file

@ -72,11 +72,12 @@ class ItemRange {
} }
export class LazyListView extends ListView { export class LazyListView extends ListView {
constructor({itemHeight, overflowMargin = 5, overflowItems = 20,...options}, childCreator) { constructor({itemHeight, onRangeVisible, overflowMargin = 5, overflowItems = 20,...options}, childCreator) {
super(options, childCreator); super(options, childCreator);
this._itemHeight = itemHeight; this._itemHeight = itemHeight;
this._overflowMargin = overflowMargin; this._overflowMargin = overflowMargin;
this._overflowItems = overflowItems; this._overflowItems = overflowItems;
this._onRangeVisible = onRangeVisible; // function(ItemRange)
} }
_getVisibleRange() { _getVisibleRange() {
@ -103,6 +104,9 @@ export class LazyListView extends ListView {
if (forceRender || !this._renderRange.contains(intersectRange)) { if (forceRender || !this._renderRange.contains(intersectRange)) {
this._renderRange = renderRange; this._renderRange = renderRange;
this._renderElementsInRange(); this._renderElementsInRange();
if (this._onRangeVisible) {
this._onRangeVisible(renderRange);
}
} }
} }

View file

@ -64,6 +64,9 @@ export class LeftPanelView extends TemplateView {
className: "RoomList", className: "RoomList",
itemHeight: 44, itemHeight: 44,
list: vm.tileViewModels, list: vm.tileViewModels,
onRangeVisible: (range) => {
console.log(range);
},
}, },
tileVM => { tileVM => {
if (tileVM.kind === "invite") { if (tileVM.kind === "invite") {