[ASCollectionView] When resizing, invalidate after remeasuring all nodes (#1931)

This commit is contained in:
Adlai Holler
2016-07-15 16:32:23 -07:00
committed by appleguy
parent 3b09cbb845
commit dda7accd8e
2 changed files with 5 additions and 6 deletions

View File

@@ -100,7 +100,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
id<ASCollectionViewLayoutFacilitatorProtocol> _layoutFacilitator;
BOOL _performingBatchUpdates;
BOOL _superPerformingBatchUpdates;
NSUInteger _superBatchUpdateCount;
NSMutableArray *_batchUpdateBlocks;
BOOL _isDeallocating;
@@ -518,11 +518,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
- (void)_superPerformBatchUpdates:(void(^)())updates completion:(void(^)(BOOL finished))completion
{
ASDisplayNodeAssertMainThread();
ASDisplayNodeAssert(_superPerformingBatchUpdates == NO, @"Nested batch updates being sent to UICollectionView. This is not expected.");
_superPerformingBatchUpdates = YES;
_superBatchUpdateCount++;
[super performBatchUpdates:updates completion:completion];
_superPerformingBatchUpdates = NO;
_superBatchUpdateCount--;
}
#pragma mark Assertions.
@@ -849,6 +848,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
} completion:nil];
// We need to ensure the size requery is done before we update our layout.
[self waitUntilAllUpdatesAreCommitted];
[self.collectionViewLayout invalidateLayout];
}
}
@@ -857,7 +857,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
_nextLayoutInvalidationStyle = ASCollectionViewInvalidationStyleNone;
switch (invalidationStyle) {
case ASCollectionViewInvalidationStyleWithAnimation:
if (!_superPerformingBatchUpdates) {
if (0 == _superBatchUpdateCount) {
[self _superPerformBatchUpdates:^{ } completion:nil];
}
break;