Skip to content

Commit

Permalink
Added estimated number of rows for UICollectionViewFlowLayout with ve…
Browse files Browse the repository at this point in the history
…rtical scroll direction. (#385)
  • Loading branch information
StasMalinovsky committed Apr 30, 2021
1 parent 19e7866 commit 62193db
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ extension UICollectionView: CollectionSkeleton {
var estimatedNumberOfRows: Int {
guard let flowlayout = collectionViewLayout as? UICollectionViewFlowLayout else { return 0 }
return Int(ceil(frame.height / flowlayout.itemSize.height))
switch flowlayout.scrollDirection {
case .vertical:
return Int(ceil(frame.height / flowlayout.itemSize.height))
case .horizontal:
return Int(ceil(frame.width / flowlayout.itemSize.width))
default:
return 0
}
}

var skeletonDataSource: SkeletonCollectionDataSource? {
Expand Down

0 comments on commit 62193db

Please sign in to comment.