diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index 033aaa87..4c2741df 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -927,6 +927,22 @@ return nil; } +- (NSArray *)fullyVisibleCellsForSectionController:(IGListSectionController *)sectionController { + NSMutableArray *cells = [NSMutableArray new]; + UICollectionView *collectionView = self.collectionView; + NSArray *visibleCells = [collectionView visibleCells]; + const NSInteger section = [self sectionForSectionController:sectionController]; + for (UICollectionViewCell *cell in visibleCells) { + if ([collectionView indexPathForCell:cell].section == section) { + const CGRect cellRect = [cell convertRect:cell.bounds toView:collectionView]; + if (CGRectContainsRect(UIEdgeInsetsInsetRect(collectionView.bounds, collectionView.contentInset), cellRect)) { + [cells addObject:cell]; + } + } + } + return cells; +} + - (NSArray *)visibleCellsForSectionController:(IGListSectionController *)sectionController { NSMutableArray *cells = [NSMutableArray new]; UICollectionView *collectionView = self.collectionView; diff --git a/Source/IGListKit/IGListCollectionContext.h b/Source/IGListKit/IGListCollectionContext.h index 29bd3f32..be16b3ea 100644 --- a/Source/IGListKit/IGListCollectionContext.h +++ b/Source/IGListKit/IGListCollectionContext.h @@ -85,6 +85,15 @@ NS_SWIFT_NAME(ListCollectionContext) - (nullable __kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index sectionController:(IGListSectionController *)sectionController; +/** + Returns the fully visible cells for the given section controller. + + @param sectionController The section controller requesting this information. + + @return An array of fully visible cells, or an empty array if none are found. + */ +- (NSArray *)fullyVisibleCellsForSectionController:(IGListSectionController *)sectionController; + /** Returns the visible cells for the given section controller.