[ASRangeController] Don't bother asking UIKit for the visible index paths if view is zero-sized, as it triggers a reloadData.

This commit is contained in:
Scott Goodson
2016-03-10 19:10:25 -08:00
parent aab2ecc26e
commit 0e460ca00a
3 changed files with 21 additions and 5 deletions

View File

@@ -867,7 +867,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
- (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeController
{
ASDisplayNodeAssertMainThread();
return [self indexPathsForVisibleItems];
// Calling visibleNodeIndexPathsForRangeController: will trigger UIKit to call reloadData if it never has, which can result
// in incorrect layout if performed at zero size. We can use the fact that nothing can be visible at zero size to return fast.
BOOL isZeroSized = CGRectEqualToRect(self.bounds, CGRectZero);
return isZeroSized ? @[] : [self indexPathsForVisibleItems];
}
- (CGSize)viewportSizeForRangeController:(ASRangeController *)rangeController