Skip to content

Commit

Permalink
[ASCollectionView] Improve performance and behavior of rotation / bou…
Browse files Browse the repository at this point in the history
…nds changes.

See #430 for details.
  • Loading branch information
appleguy committed Jul 9, 2017
1 parent bc361ca commit 46743ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2156,10 +2156,12 @@ - (void)layer:(CALayer *)layer didChangeBoundsWithOldValue:(CGRect)oldBounds new
BOOL changedInNonScrollingDirection = (fixedHorizontally && newBounds.size.width != lastUsedSize.width) || (fixedVertically && newBounds.size.height != lastUsedSize.height);

if (changedInNonScrollingDirection) {
[_dataController relayoutAllNodes];
[_dataController waitUntilAllUpdatesAreCommitted];
// We need to ensure the size requery is done before we update our layout.
// Because -invalidateLayout doesn't trigger any operations by itself, and we answer queries from UICollectionView using layoutThatFits:,
// we invalidate the layout before we have updated all of the cells. Any cells that the collection needs the size of immediately will get
// -layoutThatFits: with a new constraint, on the main thread, and synchronously calculate them. Meanwhile, relayoutAllNodes will update
// the layout of any remaining nodes on background threads (and fast-return for any nodes that the UICV got to first).
[self.collectionViewLayout invalidateLayout];
[_dataController relayoutAllNodes];
}
}

Expand Down

0 comments on commit 46743ad

Please sign in to comment.