From cde33a2d69a64ce0c3b41628deb4823997a02923 Mon Sep 17 00:00:00 2001 From: Anil Chembath Date: Thu, 8 Aug 2019 14:09:06 +0530 Subject: [PATCH] Resolved issue of rendering initialRenderIndex in web (#393) --- package.json | 2 +- src/core/ViewabilityTracker.ts | 3 +++ src/core/VirtualRenderer.ts | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7b7b8f0d..3c59a640 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recyclerlistview", - "version": "2.0.10-beta.3", + "version": "2.0.10-beta.4", "description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.", "main": "dist/reactnative/index.js", "types": "dist/reactnative/index.d.ts", diff --git a/src/core/ViewabilityTracker.ts b/src/core/ViewabilityTracker.ts index bdfa5fb1..25cfb895 100644 --- a/src/core/ViewabilityTracker.ts +++ b/src/core/ViewabilityTracker.ts @@ -133,6 +133,9 @@ export default class ViewabilityTracker { public getCurrentRenderAheadOffset(): number { return this._renderAheadOffset; } + public setActualOffset(actualOffset: number): void { + this._actualOffset = actualOffset; + } private _findFirstVisibleIndexOptimally(): number { let firstVisibleIndex = 0; diff --git a/src/core/VirtualRenderer.ts b/src/core/VirtualRenderer.ts index 61cecbf9..10c891e5 100644 --- a/src/core/VirtualRenderer.ts +++ b/src/core/VirtualRenderer.ts @@ -88,14 +88,14 @@ export default class VirtualRenderer { public updateOffset(offsetX: number, offsetY: number, correction: number, isActual: boolean): void { if (this._viewabilityTracker) { + const offset = this._params && this._params.isHorizontal ? offsetX : offsetY; if (!this._isViewTrackerRunning) { + if (isActual) { + this._viewabilityTracker.setActualOffset(offset); + } this.startViewabilityTracker(); } - if (this._params && this._params.isHorizontal) { - this._viewabilityTracker.updateOffset(offsetX, correction, isActual); - } else { - this._viewabilityTracker.updateOffset(offsetY, correction, isActual); - } + this._viewabilityTracker.updateOffset(offset, correction, isActual); } }