@@ -74,7 +74,6 @@ export type ViewabilityConfig = {|
74
74
class ViewabilityHelper {
75
75
_config : ViewabilityConfig ;
76
76
_hasInteracted : boolean = false ;
77
- _lastUpdateTime : number = 0 ;
78
77
_timers : Set < number > = new Set ( ) ;
79
78
_viewableIndices : Array < number > = [ ] ;
80
79
_viewableItems : Map < string , ViewToken > = new Map ( ) ;
@@ -170,15 +169,11 @@ class ViewabilityHelper {
170
169
} ) = > void ,
171
170
renderRange ?: { first : number , last : number } , // Optional optimization to reduce the scan size
172
171
) : void {
173
- const updateTime = Date . now ( ) ;
174
- if ( this . _lastUpdateTime === 0 && itemCount > 0 && getFrameMetrics ( 0 ) ) {
175
- // Only count updates after the first item is rendered and has a frame.
176
- this . _lastUpdateTime = updateTime ;
177
- }
178
- const updateElapsed = this . _lastUpdateTime
179
- ? updateTime - this . _lastUpdateTime
180
- : 0 ;
181
- if ( this . _config . waitForInteraction && ! this . _hasInteracted ) {
172
+ if (
173
+ ( this . _config . waitForInteraction && ! this . _hasInteracted ) ||
174
+ itemCount === 0 ||
175
+ ! getFrameMetrics ( 0 )
176
+ ) {
182
177
return ;
183
178
}
184
179
let viewableIndices = [ ] ;
@@ -200,11 +195,7 @@ class ViewabilityHelper {
200
195
return ;
201
196
}
202
197
this . _viewableIndices = viewableIndices ;
203
- this . _lastUpdateTime = updateTime ;
204
- if (
205
- this . _config . minimumViewTime &&
206
- updateElapsed < this . _config . minimumViewTime
207
- ) {
198
+ if ( this . _config . minimumViewTime ) {
208
199
const handle = setTimeout ( ( ) => {
209
200
this . _timers . delete ( handle ) ;
210
201
this . _onUpdateSync (
0 commit comments