Check out example codes for "UICollectionView current visible cell index". It will help you in understanding the concepts better.

Code Example 1

let visibleRect = CGRect(origin: collectionView.contentOffset, size: collectionView.bounds.size)
let visiblePoint = CGPoint(x: visibleRect.midX, y: visibleRect.midY)
let visibleIndexPath = collectionView.indexPathForItem(at: visiblePoint)

Learn ReactJs, React Native from akashmittal.com