From 9bc58dc024e20a6d82916c6d0007e08790dca020 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 5 Dec 2016 15:00:39 -0800 Subject: [PATCH] When not visible, only batch fetch to fill visible area --- AsyncDisplayKit/ASCollectionView.mm | 6 +++++ AsyncDisplayKit/ASTableView.mm | 6 +++++ AsyncDisplayKit/Private/ASBatchFetching.h | 4 ++- AsyncDisplayKit/Private/ASBatchFetching.m | 15 ++++++++--- AsyncDisplayKitTests/ASBatchFetchingTests.m | 28 ++++++++++----------- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index 5d31f49a4c..642a9fb825 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -1708,6 +1708,12 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; [_rangeController setNeedsUpdate]; [_rangeController updateIfNeeded]; } + + // When we aren't visible, we will only fetch up to the visible area. Now that we are visible, + // we will fetch visible area + leading screens, so we need to check. + if (visible) { + [self _checkForBatchFetching]; + } } #pragma mark ASCALayerExtendedDelegate diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 1f0ec1d5c2..44da18d057 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -1725,6 +1725,12 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; [_rangeController setNeedsUpdate]; [_rangeController updateIfNeeded]; } + + // When we aren't visible, we will only fetch up to the visible area. Now that we are visible, + // we will fetch visible area + leading screens, so we need to check. + if (visible) { + [self _checkForBatchFetching]; + } } @end diff --git a/AsyncDisplayKit/Private/ASBatchFetching.h b/AsyncDisplayKit/Private/ASBatchFetching.h index a09fb898d3..7effc6bcb7 100644 --- a/AsyncDisplayKit/Private/ASBatchFetching.h +++ b/AsyncDisplayKit/Private/ASBatchFetching.h @@ -45,6 +45,7 @@ BOOL ASDisplayShouldFetchBatchForScrollView(UIScrollView