[ASCollectionLayout] Manually set size to measured cells #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Ported from facebookarchive/AsyncDisplayKit#3262)
Currently, ASDataController sets the calculated size of a cell node right after measuring it (here). This behavior dates all the way back to the first implementation of ASDataController. This is to ensure that by the time the cell needs to display, it has a valid size and the needsLayout flag of its layer is on. Failing to do so will cause it to skip its display pass entirely.
ASCollectionLayout currently doesn't do this which causes some cells to be missing. This PR updates ASCollectionLayout to set the frame whenever a node's layout attributes is asked.
There are 2 other places we can fix this:
When the cell node applies its layout attributes. This event is driven by UICollectionView and is often too late. We want all cell nodes that are not only in visible range but also display and preload ranges to have a correct size.
When the cell node enters preload range: Inside didEnterPreloadState, the node needs to grab its calculated size and assumes that the size is valid. However, I'd prefer ASCollectionLayout to be in charge of these kind of decisions.
Ticket: #186