Fix onRemove

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-10 18:44:00 +05:30 committed by Bruno Windels
parent 83ff2dd810
commit 1165683f69

View file

@ -289,8 +289,29 @@ export class LazyListView extends ListView {
this._adjustPadding(this._renderRange);
}
onRemove() {
this._renderIfNeeded(true);
onRemove(idx, value) {
const {topCount, renderCount, bottomCount} = this._renderRange;
if (this._renderRange.containsIndex(idx)) {
const normalizedIdx = this._renderRange.normalize(idx);
super.onRemove(normalizedIdx, value);
if (bottomCount === 0) {
const child = this._childCreator(this._itemAtIndex(topCount - 1));
this._childInstances.unshift(child);
this._root.insertBefore(mountView(child, this._mountArgs), this._root.firstChild);
this._renderRange = new ItemRange(topCount - 1, renderCount, bottomCount);
}
else {
const child = this._childCreator(this._itemAtIndex(this._renderRange.lastIndex - 1));
this._childInstances.push(child);
this._root.appendChild(mountView(child, this._mountArgs));
this._renderRange = new ItemRange(topCount, renderCount, bottomCount - 1);
}
}
else {
this._renderRange = idx < topCount ? new ItemRange(topCount - 1, renderCount, bottomCount):
new ItemRange(topCount, renderCount, bottomCount - 1);
}
this._adjustPadding(this._renderRange);
}
onUpdate(idx, value, params) {