Reputation: 3
I am using a diffable datasource with a compositional layout. My CollectionView has expandable cells. When I try to update the cell's expanded state using applySnapshot with animation, the CollectionView changes its scroll position. However, when I do this without animation, everything works fine, and the scroll position does not change when the cell height is updated. How can I do this with animation? It is my section layout configuration:
private func makeSectionlayout(environment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection {
let itemWidth = view.frame.width - Constants.Layout.sectionInsets.horizontal
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(itemWidth),
heightDimension: .estimated(400))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupWidth = environment.container.contentSize.width - Constants.Layout.sectionInsets.horizontal
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(groupWidth),
heightDimension: .estimated(400))
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item])
group.interItemSpacing = .fixed(16)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = Constants.Layout.sectionInsets
section.interGroupSpacing = 16
return section
}
Upvotes: 0
Views: 21