Skip forcing layout when UICollectionView is invisible #trivial (#1268)

Summary:
Issue fixed: # https://github.com/Instagram/IGListKit/issues/1267

- [ ] All tests pass. Demo project builds and runs.
- [ ] I added tests, an experiment, or detailed why my change isn't tested.
- [ ] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [ ] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1268

Reviewed By: maxoll

Differential Revision: D12839019

Pulled By: rnystrom

fbshipit-source-id: c695d66234d7d1969f9f17f55cbe9d7967970adc
This commit is contained in:
Jiecong Wang 2018-11-01 14:55:49 -07:00 committed by Facebook Github Bot
parent 8ebde97b92
commit c3ae2906c9
2 changed files with 6 additions and 1 deletions

View file

@ -24,6 +24,8 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentDeferredToObjectCreation = 1 << 6,
/// Test getting collection view at update time.
IGListExperimentGetCollectionViewAtUpdate = 1 << 7,
/// Test skipping layout when UICollectionView isn't visible
IGListExperimentSkipLayout = 1 << 8,
};
/**

View file

@ -176,7 +176,10 @@
[self _cleanStateAfterUpdates];
[self _performBatchUpdatesItemBlockApplied];
[collectionView reloadData];
[collectionView layoutIfNeeded];
if (!IGListExperimentEnabled(self.experiments, IGListExperimentSkipLayout)
|| collectionView.window != nil) {
[collectionView layoutIfNeeded];
}
executeCompletionBlocks(YES);
};