Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ public void UpdateLayout(UICollectionViewLayout newLayout)
ScrollDirection = compositionalLayout.Configuration.ScrollDirection;
}

// Preserve the content offset before updating the layout.
// SetCollectionViewLayout with animated:false can unexpectedly shift the content offset
// on UICollectionViewCompositionalLayout with estimated item sizes.
var savedOffset = CollectionView.ContentOffset;

ItemsViewLayout = newLayout;
_initialized = false;

EnsureLayoutInitialized();

if (_initialized)
{
// Restore the content offset that may have been changed by SetCollectionViewLayout
CollectionView.ContentOffset = savedOffset;
// Reload the data so the currently visible cells get laid out according to the new layout
ReloadData();
}
Expand Down
Loading