Remove listHasChangedSize

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-07-14 18:06:33 +05:30
parent c073d4c0d0
commit fe4f6d2308

View file

@ -73,19 +73,17 @@ export class LazyListView extends ListView {
return new ItemRange(topCount, renderCount, bottomCount); return new ItemRange(topCount, renderCount, bottomCount);
} }
_renderIfNeeded() { _renderIfNeeded(forceRender = false) {
/*
forceRender only because we don't optimize onAdd/onRemove yet.
Ideally, onAdd/onRemove should only render whatever has changed + update padding + update renderRange
*/
const range = this._getVisibleRange(); const range = this._getVisibleRange();
const intersectRange = range.expand(this._overflowMargin); const intersectRange = range.expand(this._overflowMargin);
const renderRange = range.expand(this._overflowItems); const renderRange = range.expand(this._overflowItems);
const listHasChangedSize = !!this._renderRange && this._list.length !== this._renderRange.totalSize();
// console.log("currentRange", range);
// console.log("renderRange", renderRange);
// console.log("intersectRange", intersectRange);
// console.log("LastRenderedRange", this._renderRange);
// only update render Range if the new range + overflowMargin isn't contained by the old anymore // only update render Range if the new range + overflowMargin isn't contained by the old anymore
if (listHasChangedSize || !this._renderRange.contains(intersectRange)) { // or if we are force rendering
// console.log("New render change"); if (forceRender || !this._renderRange.contains(intersectRange)) {
// console.log("scrollTop", this._parent.scrollTop);
this._renderRange = renderRange; this._renderRange = renderRange;
this._renderElementsInRange(); this._renderElementsInRange();
} }
@ -176,11 +174,11 @@ export class LazyListView extends ListView {
// If size of the list changes, re-render // If size of the list changes, re-render
onAdd() { onAdd() {
this._renderIfNeeded(); this._renderIfNeeded(true);
} }
onRemove() { onRemove() {
this._renderIfNeeded(); this._renderIfNeeded(true);
} }
onUpdate(idx, value, params) { onUpdate(idx, value, params) {