Add fullyVisibleCellsForSectionController to IGListCollectionContext [IGListKit]

Reviewed By: chritto

Differential Revision: D20261859

fbshipit-source-id: 919132f935462c2a57270f0afaba511adc936995
This commit is contained in:
Andy Wang 2020-03-09 17:46:34 -07:00 committed by Facebook Github Bot
parent c321831b80
commit 68e58bf60e
2 changed files with 25 additions and 0 deletions

View file

@ -927,6 +927,22 @@
return nil;
}
- (NSArray<UICollectionViewCell *> *)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<UICollectionViewCell *> *)visibleCellsForSectionController:(IGListSectionController *)sectionController {
NSMutableArray *cells = [NSMutableArray new];
UICollectionView *collectionView = self.collectionView;

View file

@ -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<UICollectionViewCell *> *)fullyVisibleCellsForSectionController:(IGListSectionController *)sectionController;
/**
Returns the visible cells for the given section controller.