@@ -49,6 +49,7 @@ class ViewabilityHelper {
4949 horizontal : boolean ,
5050 scrollOffset : number ,
5151 bottomViewabilityInset : number ,
52+ topViewabilityInset : number ,
5253 listSize : Dimension ,
5354 getLayout : ( index : number ) => Layout | undefined ,
5455 viewableIndices ?: number [ ]
@@ -78,6 +79,7 @@ class ViewabilityHelper {
7879 horizontal ,
7980 scrollOffset ,
8081 bottomViewabilityInset ,
82+ topViewabilityInset ,
8183 listSize ,
8284 this . viewabilityConfig ?. viewAreaCoveragePercentThreshold ,
8385 this . viewabilityConfig ?. itemVisiblePercentThreshold ,
@@ -127,6 +129,7 @@ class ViewabilityHelper {
127129 horizontal : boolean ,
128130 scrollOffset : number ,
129131 bottomViewabilityInset : number ,
132+ topViewabilityInset : number ,
130133 listSize : Dimension ,
131134 viewAreaCoveragePercentThreshold : number | null | undefined ,
132135 itemVisiblePercentThreshold : number | null | undefined ,
@@ -139,10 +142,11 @@ class ViewabilityHelper {
139142 const itemTop = ( horizontal ? itemLayout . x : itemLayout . y ) - scrollOffset ;
140143 const itemSize = horizontal ? itemLayout . width : itemLayout . height ;
141144 const listMainSize = horizontal
142- ? listSize . width
143- : listSize . height - bottomViewabilityInset ;
145+ ? listSize . width - topViewabilityInset - bottomViewabilityInset
146+ : listSize . height - topViewabilityInset - bottomViewabilityInset ;
144147 const pixelsVisible =
145- Math . min ( itemTop + itemSize , listMainSize ) - Math . max ( itemTop , 0 ) ;
148+ Math . min ( itemTop + itemSize , listMainSize + topViewabilityInset ) -
149+ Math . max ( itemTop , 0 ) ;
146150
147151 // Always consider item fully viewable if it is fully visible, regardless of the `viewAreaCoveragePercentThreshold`
148152 // Account for floating point imprecision.
@@ -157,7 +161,7 @@ class ViewabilityHelper {
157161 viewAreaCoveragePercentThreshold !== null &&
158162 viewAreaCoveragePercentThreshold !== undefined ;
159163 const percent = viewAreaMode
160- ? pixelsVisible / listMainSize
164+ ? pixelsVisible / ( listMainSize + topViewabilityInset )
161165 : pixelsVisible / itemSize ;
162166 const viewableAreaPercentThreshold = viewAreaMode
163167 ? viewAreaCoveragePercentThreshold * 0.01
0 commit comments