forked from mystiq/hydrogen-web
Remove listHasChangedSize
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
c073d4c0d0
commit
fe4f6d2308
1 changed files with 10 additions and 12 deletions
|
@ -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();
|
// only update render Range if the new range + overflowMargin isn't contained by the old anymore
|
||||||
// console.log("currentRange", range);
|
// or if we are force rendering
|
||||||
// console.log("renderRange", renderRange);
|
if (forceRender || !this._renderRange.contains(intersectRange)) {
|
||||||
// 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
|
|
||||||
if (listHasChangedSize || !this._renderRange.contains(intersectRange)) {
|
|
||||||
// console.log("New render change");
|
|
||||||
// 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) {
|
||||||
|
|
Loading…
Reference in a new issue