From 337532faf43f9ea80bf999a5e87861e6504381fd Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Mar 2020 12:03:46 +0700 Subject: [PATCH 1/8] prevent recycle to hard and collision stable id --- src/core/VirtualRenderer.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index c6cdfc95..fa0ae350 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -282,7 +282,9 @@ export default class VirtualRenderer { delete this._stableIdToRenderKeyMap[key]; } } - + if(shouldOptimizeForAnimations && this._isRecyclingEnabled) { + this._recyclePool.clearAll(); + } for (const key in this._renderStack) { if (this._renderStack.hasOwnProperty(key)) { const index = this._renderStack[key].dataIndex; @@ -305,13 +307,14 @@ export default class VirtualRenderer { } } Object.assign(this._renderStack, newRenderStack); - - for (const key in this._renderStack) { - if (this._renderStack.hasOwnProperty(key)) { - const index = this._renderStack[key].dataIndex; - if (!ObjectUtil.isNullOrUndefined(index) && ObjectUtil.isNullOrUndefined(this._engagedIndexes[index])) { - const type = this._layoutProvider.getLayoutTypeForIndex(index); - this._recyclePool.putRecycledObject(type, key); + if(!shouldOptimizeForAnimations && this._isRecyclingEnabled) { + for (const key in this._renderStack) { + if (this._renderStack.hasOwnProperty(key)) { + const index = this._renderStack[key].dataIndex; + if (!ObjectUtil.isNullOrUndefined(index) && ObjectUtil.isNullOrUndefined(this._engagedIndexes[index])) { + const type = this._layoutProvider.getLayoutTypeForIndex(index); + this._recyclePool.putRecycledObject(type, key); + } } } } From 5071d44d03d5eca4ab809726c1116ee53f3544ba Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Mar 2020 12:10:38 +0700 Subject: [PATCH 2/8] fix tslint --- src/core/VirtualRenderer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index fa0ae350..cb80c9f6 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -282,7 +282,7 @@ export default class VirtualRenderer { delete this._stableIdToRenderKeyMap[key]; } } - if(shouldOptimizeForAnimations && this._isRecyclingEnabled) { + if (shouldOptimizeForAnimations && this._isRecyclingEnabled) { this._recyclePool.clearAll(); } for (const key in this._renderStack) { @@ -307,7 +307,7 @@ export default class VirtualRenderer { } } Object.assign(this._renderStack, newRenderStack); - if(!shouldOptimizeForAnimations && this._isRecyclingEnabled) { + if (!shouldOptimizeForAnimations && this._isRecyclingEnabled) { for (const key in this._renderStack) { if (this._renderStack.hasOwnProperty(key)) { const index = this._renderStack[key].dataIndex; From e8cc06d0c596327fda549e131108886eb2cadb19 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Mar 2020 14:41:09 +0700 Subject: [PATCH 3/8] optimize for insert at bottom animation --- src/core/dependencies/DataProvider.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/dependencies/DataProvider.ts b/src/core/dependencies/DataProvider.ts index 5fffb4ea..4cf7ba6e 100644 --- a/src/core/dependencies/DataProvider.ts +++ b/src/core/dependencies/DataProvider.ts @@ -53,7 +53,7 @@ export abstract class BaseDataProvider { //No need to override this one //If you already know the first row where rowHasChanged will be false pass it upfront to avoid loop - public cloneWithRows(newData: any[], firstModifiedIndex?: number): DataProvider { + public cloneWithRows(newData: any[], firstModifiedIndex?: number, optimizeForInsertAtBottomAnimation?: boolean): DataProvider { const dp = this.newInstance(this.rowHasChanged, this.getStableId); const newSize = newData.length; const iterCount = Math.min(this._size, newSize); @@ -70,6 +70,10 @@ export abstract class BaseDataProvider { } if (dp._firstIndexToProcess !== this._data.length) { dp._requiresDataChangeHandling = true; + } else { + if (optimizeForInsertAtBottomAnimation && this._data.length < newSize) { + dp._requiresDataChangeHandling = true; + } } dp._data = newData; dp._size = newSize; From 3d2adaff22f05fef16bbe64edeb410842b741a4f Mon Sep 17 00:00:00 2001 From: khanh Date: Fri, 13 Mar 2020 00:54:25 +0700 Subject: [PATCH 4/8] generate Collision Avoiding Key for new stableId --- src/core/VirtualRenderer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index cb80c9f6..9fb3a8f5 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -38,6 +38,7 @@ export default class VirtualRenderer { private _stableIdToRenderKeyMap: { [key: string]: StableIdMapItem | undefined }; private _engagedIndexes: { [key: number]: number | undefined }; private _renderStack: RenderStack; + private _cachedRenderStack: RenderStack; private _renderStackChanged: (renderStack: RenderStack) => void; private _fetchStableId: StableIdProvider; private _isRecyclingEnabled: boolean; @@ -58,6 +59,7 @@ export default class VirtualRenderer { isRecyclingEnabled: boolean) { //Keeps track of items that need to be rendered in the next render cycle this._renderStack = {}; + this._cachedRenderStack = {}; this._fetchStableId = fetchStableId; @@ -225,6 +227,10 @@ export default class VirtualRenderer { } } else { key = getStableId(index); + if(this._cachedRenderStack[key]) { + delete this._cachedRenderStack[key]; + key = this._getCollisionAvoidingKey(); + } if (renderStack[key]) { //Probable collision, warn and avoid //TODO: Disabled incorrectly triggering in some cases @@ -285,6 +291,7 @@ export default class VirtualRenderer { if (shouldOptimizeForAnimations && this._isRecyclingEnabled) { this._recyclePool.clearAll(); } + this._cachedRenderStack = Object.assign({}, this._renderStack); for (const key in this._renderStack) { if (this._renderStack.hasOwnProperty(key)) { const index = this._renderStack[key].dataIndex; @@ -306,6 +313,7 @@ export default class VirtualRenderer { delete this._renderStack[key]; } } + this._cachedRenderStack = {}; Object.assign(this._renderStack, newRenderStack); if (!shouldOptimizeForAnimations && this._isRecyclingEnabled) { for (const key in this._renderStack) { From ffd4fc39c4ed38285fdc1d3c27fc69e490697f31 Mon Sep 17 00:00:00 2001 From: khanh Date: Fri, 13 Mar 2020 00:58:26 +0700 Subject: [PATCH 5/8] fix tslint --- src/core/VirtualRenderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index 9fb3a8f5..1d3dabe2 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -227,7 +227,7 @@ export default class VirtualRenderer { } } else { key = getStableId(index); - if(this._cachedRenderStack[key]) { + if (this._cachedRenderStack[key]) { delete this._cachedRenderStack[key]; key = this._getCollisionAvoidingKey(); } From 8c03089f23d78296d7c4a0502b31ef4fd6b83cd2 Mon Sep 17 00:00:00 2001 From: khanh Date: Sun, 29 Mar 2020 21:31:21 +0700 Subject: [PATCH 6/8] fix clearAll of null --- src/core/VirtualRenderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index 1d3dabe2..29025674 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -288,7 +288,7 @@ export default class VirtualRenderer { delete this._stableIdToRenderKeyMap[key]; } } - if (shouldOptimizeForAnimations && this._isRecyclingEnabled) { + if (shouldOptimizeForAnimations && this._isRecyclingEnabled && this._recyclePool) { this._recyclePool.clearAll(); } this._cachedRenderStack = Object.assign({}, this._renderStack); From b5b9f22a3d0437a93f0d317557a746911b6df13b Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Wed, 6 May 2020 11:58:10 +0700 Subject: [PATCH 7/8] fix first sticky header visible when scroll to top --- src/core/sticky/StickyHeader.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/sticky/StickyHeader.tsx b/src/core/sticky/StickyHeader.tsx index 522072e6..f56ba950 100644 --- a/src/core/sticky/StickyHeader.tsx +++ b/src/core/sticky/StickyHeader.tsx @@ -62,7 +62,6 @@ export default class StickyHeader

extends StickyObj } protected hasReachedBoundary(offsetY: number, _windowBound?: number): boolean { - //TODO (Swapnil) Refer to talha and understand what needs to be done. - return false; + return offsetY <= 0; } } From 4af7ddd63ba161fd8bec8bf74579b0d15211423d Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Tue, 9 Mar 2021 10:16:26 +0700 Subject: [PATCH 8/8] fix scrollToOffset --- src/core/RecyclerListView.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/RecyclerListView.tsx b/src/core/RecyclerListView.tsx index 1ee6ccb7..69347c14 100644 --- a/src/core/RecyclerListView.tsx +++ b/src/core/RecyclerListView.tsx @@ -400,7 +400,9 @@ export default class RecyclerListView

{ - this.scrollToOffset(offset.x, offset.y, false); + if (offset.x >= 0 && offset.y >= 0) { + this.scrollToOffset(offset.x, offset.y, false); + } }, 0); } }