diff --git a/Source/IGListDiffKit/IGListExperiments.h b/Source/IGListDiffKit/IGListExperiments.h index 1c660a88c..4fa764e7d 100644 --- a/Source/IGListDiffKit/IGListExperiments.h +++ b/Source/IGListDiffKit/IGListExperiments.h @@ -21,7 +21,9 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) { /// Throw NSInternalInconsistencyException during an update IGListExperimentThrowOnInconsistencyException = 1 << 3, /// Test keeping a strong pointer to the collectionView.dataSource during a batch update to avoid a crash - IGListExperimentKeepPointerToCollectionViewDataSource = 1 << 4 + IGListExperimentKeepPointerToCollectionViewDataSource = 1 << 4, + /// Test keeping disable all animation on updates + IGListExperimentDisableAnimationOnUpdates= 1 << 5 }; /** diff --git a/Source/IGListKit/IGListAdapter.h b/Source/IGListKit/IGListAdapter.h index de6a34f62..1d702ec00 100644 --- a/Source/IGListKit/IGListAdapter.h +++ b/Source/IGListKit/IGListAdapter.h @@ -103,6 +103,7 @@ NS_SWIFT_NAME(ListAdapter) */ @property (nonatomic, assign) IGListExperiment experiments; + /** Initializes a new `IGListAdapter` object. diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index 0edf57470..2761206dd 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -414,7 +414,7 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio [strongSelf _updateWithData:data]; } }; - + const BOOL shouldAnimateUpdates = animated && !IGListExperimentEnabled(self.experiments, IGListExperimentDisableAnimationOnUpdates); IGListUpdaterCompletion outerCompletionBlock = ^(BOOL finished){ __typeof__(self) strongSelf = weakSelf; if (strongSelf == nil) { @@ -424,7 +424,7 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio // release the previous items strongSelf.previousSectionMap = nil; - [strongSelf _notifyDidUpdate:IGListAdapterUpdateTypePerformUpdates animated:animated]; + [strongSelf _notifyDidUpdate:IGListAdapterUpdateTypePerformUpdates animated:shouldAnimateUpdates]; IGLK_BLOCK_CALL_SAFE(completion,finished); [strongSelf _exitBatchUpdates]; }; @@ -686,7 +686,7 @@ - (IGListTransitionData *)_generateTransitionDataWithObjects:(NSArray *)objects dataSource, object); return; } - + if ([sectionController isMemberOfClass:[IGListSectionController class]]) { // If IGListSectionController is not subclassed, it could be a side effect of a problem. For example, nothing stops // dataSource from returning a plain IGListSectionController if it doesn't recognize the object type, instead of throwing. @@ -1367,7 +1367,7 @@ - (void)insertInSectionController:(IGListSectionController *)sectionController a NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes usePreviousIfInUpdateBlock:NO]; [self.updater insertItemsIntoCollectionView:collectionView indexPaths:indexPaths]; - + if (![self isInDataUpdateBlock]) { [self _updateBackgroundView]; } @@ -1386,7 +1386,7 @@ - (void)deleteInSectionController:(IGListSectionController *)sectionController a NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes usePreviousIfInUpdateBlock:YES]; [self.updater deleteItemsFromCollectionView:collectionView indexPaths:indexPaths]; - + if (![self isInDataUpdateBlock]) { [self _updateBackgroundView]; }