I did UICollectionViewCompositionalLayout with orthogonal section with groupPagingCentered as follow:
func neighborsRealitiesSection() -> NSCollectionLayoutSection {
	let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
	let item = NSCollectionLayoutItem(layoutSize: itemSize)
		
	let cellWidth = UIScreen.main.bounds.width / 3 + 1
	let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth), heightDimension: .absolute(cellWidth))
	let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item])
		
	let section = NSCollectionLayoutSection(group: group)
	section.orthogonalScrollingBehavior = .groupPagingCentered
		
	section.visibleItemsInvalidationHandler = { items, offset, environment in
		items.filter { $0.representedElementKind != UICollectionView.elementKindSectionHeader }.forEach { item in
			let distanceFromCenter = abs((item.frame.midX - offset.x) - environment.container.contentSize.width / 2.0)
			let minScale: CGFloat = 0.7
			let maxScale: CGFloat = 1
			let scale = max(maxScale - (distanceFromCenter / environment.container.contentSize.width), minScale)
				
			item.transform = CGAffineTransform(scale: scale)
		}
	}
}
The other sections are scrolled vertically. When scrolling vertically, the orthogonal offset is reset to zero. If I comment on the visibleItemsInvalidationHandler, it will not be reset.
Why does it happen? Does anybody have this problem?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I did UICollectionViewCompositionalLayout with orthogonal section with groupPagingCentered as follow:
func neighborsRealitiesSection() -> NSCollectionLayoutSection {
	let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
	let item = NSCollectionLayoutItem(layoutSize: itemSize)
		
	let cellWidth = UIScreen.main.bounds.width / 3 + 1
	let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth), heightDimension: .absolute(cellWidth))
	let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item])
		
	let section = NSCollectionLayoutSection(group: group)
	section.orthogonalScrollingBehavior = .groupPaging
		
	let inset = (UIScreen.main.bounds.width - cellWidth) / 2
	section.contentInsets = .init(top: 0, leading: inset, bottom: 0, trailing: inset)
		
	return section
}
If I adding the contentInsets to the section, collectionView won't stop scrolling on the penultimate cell. It will scrolling to the next cell. If I comment on contentInsets, it will be ok.
Why does it happen? Does anybody have this problem?