Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASCollectionLayout] Manually set size to measured cells #3262

Conversation

nguyenhuy
Copy link
Contributor

@nguyenhuy nguyenhuy commented Apr 12, 2017

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: #3219

@nguyenhuy nguyenhuy force-pushed the HNMissingCellsInCollectionLayout branch from 1c99276 to f893fdf Compare April 13, 2017 10:11
@nguyenhuy nguyenhuy changed the title [ASCollectionLayout] Manually set frame to measured cells [ASCollectionLayout] Manually set size to measured cells Apr 13, 2017
@nguyenhuy nguyenhuy force-pushed the HNMissingCellsInCollectionLayout branch from f893fdf to 8739bac Compare April 13, 2017 10:12
Copy link
Contributor

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll re-approve once this is reopened on the Texture repo.

@nguyenhuy
Copy link
Contributor Author

PR ported!

@nguyenhuy nguyenhuy closed this Apr 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants