Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
[WIP] Trigger new batch fetch for collection view after layout transi…
Browse files Browse the repository at this point in the history
…tions (#1697)

[Table / Collection] Trigger new batch fetch after programmatic scrolls, or layout transitions.
  • Loading branch information
nickvelloff authored and appleguy committed Jun 22, 2016
1 parent eb9e816 commit a05d311
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ - (ASRangeController *)rangeController
- (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeController
{
ASDisplayNodeAssertMainThread();

// 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);
Expand Down Expand Up @@ -1065,6 +1066,11 @@ - (void)rangeController:(ASRangeController *)rangeController didEndUpdatesAnimat
_performingBatchUpdates = NO;
}

- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
{
[self _checkForBatchFetching];
}

- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
{
ASDisplayNodeAssertMainThread();
Expand Down
5 changes: 5 additions & 0 deletions AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,11 @@ - (void)rangeController:(ASRangeController *)rangeController didEndUpdatesAnimat
}
}

- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
{
[self _checkForBatchFetching];
}

- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
{
ASDisplayNodeAssertMainThread();
Expand Down
7 changes: 7 additions & 0 deletions AsyncDisplayKit/Details/ASRangeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)rangeController:(ASRangeController * )rangeController didEndUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion;

/**
* Completed updates to cell node addition and removal.
*
* @param rangeController Sender.
*/
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController;

/**
* Called for nodes insertion.
*
Expand Down
1 change: 1 addition & 0 deletions AsyncDisplayKit/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ - (void)_updateVisibleNodeIndexPaths
[modifiedIndexPaths sortUsingSelector:@selector(compare:)];
NSLog(@"Range update complete; modifiedIndexPaths: %@", [self descriptionWithIndexPaths:modifiedIndexPaths]);
#endif
[_delegate didCompleteUpdatesInRangeController:self];
}

#pragma mark - Notification observers
Expand Down

0 comments on commit a05d311

Please sign in to comment.