[ASDisplayNode] Trigger a layout pass whenever a node enters preload state (#3263)

* Add a thread-safe layoutIfNeeded implementation to ASDisplayNode

* Trigger a layout pass when a display node enters preload state
- This ensures that all the subnodes have the correct size to preload their content.

* ASCollectionNode to trigger its initial data load when it enters preload state

* Minor change in _ASCollectionViewCell

* Layout sublayouts before dispatch to main for subclass hooks

* Update comments

* Don't wait until updates are committed when the collection node enters display state

* Same deal for table node

* Explain the layout trigger in ASDisplayNode
This commit is contained in:
Huy Nguyen
2017-04-14 00:25:17 +01:00
committed by Adlai Holler
parent 3164d8d013
commit dcf858eac1
8 changed files with 124 additions and 44 deletions

View File

@@ -193,18 +193,20 @@
[self.rangeController clearContents];
}
- (void)didExitPreloadState
{
[super didExitPreloadState];
[self.rangeController clearPreloadedData];
}
- (void)interfaceStateDidChange:(ASInterfaceState)newState fromState:(ASInterfaceState)oldState
{
[super interfaceStateDidChange:newState fromState:oldState];
[ASRangeController layoutDebugOverlayIfNeeded];
}
- (void)didEnterPreloadState
{
// Intentionally allocate the view here so that super will trigger a layout pass on it which in turn will trigger the intial data load.
// We can get rid of this call later when ASDataController, ASRangeController and ASCollectionLayout can operate without the view.
[self view];
[super didEnterPreloadState];
}
#if ASRangeControllerLoggingEnabled
- (void)didEnterVisibleState
{
@@ -219,6 +221,12 @@
}
#endif
- (void)didExitPreloadState
{
[super didExitPreloadState];
[self.rangeController clearPreloadedData];
}
#pragma mark Setter / Getter
// TODO: Implement this without the view. Then revisit ASLayoutElementCollectionTableSetTraitCollection