From 1165683f69badc40e4354eeb6729ac796a77d551 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 10 Aug 2021 18:44:00 +0530 Subject: [PATCH] Fix onRemove Signed-off-by: RMidhunSuresh --- src/platform/web/ui/general/LazyListView.js | 25 +++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/platform/web/ui/general/LazyListView.js b/src/platform/web/ui/general/LazyListView.js index c4a1c6b9..d94487ba 100644 --- a/src/platform/web/ui/general/LazyListView.js +++ b/src/platform/web/ui/general/LazyListView.js @@ -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) {