take into account contentInset when calculating itemWidth

This commit is contained in:
Hedden, Kyle Matthew 2023-10-05 13:53:19 -04:00
parent bab59e4e5d
commit 0afa13392f

View File

@ -384,7 +384,7 @@ open class Carousel: View {
extension Carousel: UICollectionViewDelegateFlowLayout {
open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let itemWidth = collectionView.bounds.width * itemWidthPercent
let itemWidth = (collectionView.bounds.width - collectionView.contentInset.left - collectionView.contentInset.right) * itemWidthPercent
return CGSize(width: itemWidth, height: collectionView.bounds.height)
}