File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ export abstract class CollectionViewBase extends View implements CollectionViewD
179179 public abstract eachChildAsync ( callback ) ;
180180 public abstract refreshVisibleItems ( ) ;
181181 public abstract isItemAtIndexVisible ( index : number ) ;
182+ public abstract findFirstVisibleItemIndex ( ) : number ;
182183 public abstract scrollToIndex ( index : number , animated : boolean ) ;
183184 public abstract scrollToOffset ( value : number , animated ?: boolean ) : any ;
184185
Original file line number Diff line number Diff line change @@ -968,6 +968,17 @@ export class CollectionView extends CollectionViewBase {
968968 }
969969 return false ;
970970 }
971+ public findFirstVisibleItemIndex ( ) {
972+ const view = this . nativeViewProtected ;
973+ if ( ! view ) {
974+ return - 1 ;
975+ }
976+ const layoutManager = this . layoutManager as androidx . recyclerview . widget . LinearLayoutManager ;
977+ if ( layoutManager [ 'findFirstVisibleItemPosition' ] ) {
978+ return layoutManager . findFirstVisibleItemPosition ( ) ;
979+ }
980+ return - 1 ;
981+ }
971982
972983 _layedOut = false ;
973984 @profile
Original file line number Diff line number Diff line change @@ -666,7 +666,13 @@ export class CollectionView extends CollectionViewBase {
666666
667667 return indexes . some ( ( visIndex ) => visIndex . row === itemIndex ) ;
668668 }
669-
669+ public findFirstVisibleItemIndex ( ) {
670+ const view = this . nativeViewProtected ;
671+ if ( ! view ) {
672+ return - 1 ;
673+ }
674+ return view . indexPathsForVisibleItems ?. objectAtIndex ( 0 ) ?. row ?? - 1 ;
675+ }
670676 @profile
671677 public refresh ( ) {
672678 if ( ! this . isLoaded || ! this . nativeView ) {
You can’t perform that action at this time.
0 commit comments