Skip to content
Open
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
13 changes: 10 additions & 3 deletions Source/CHTCollectionViewWaterfallLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ private func > <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
@objc optional func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
columnCountFor section: Int) -> Int

@objc optional func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumColumnSpacingFor section: Int) -> CGFloat

@available(*, unavailable, renamed: "collectionView(_:layout:sizeForItemAt:)")
@objc optional func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
Expand Down Expand Up @@ -205,10 +209,13 @@ public class CHTCollectionViewWaterfallLayout: UICollectionViewLayout {
}

public func itemWidth(inSection section: Int) -> CGFloat {
let columnCount = self.columnCount(forSection: section)
let spaceColumCount = CGFloat(columnCount - 1)
let width = collectionViewContentWidth(ofSection: section)
return floor((width - (spaceColumCount * minimumColumnSpacing)) / CGFloat(columnCount))

let columnCount = self.columnCount(forSection: section)
let spaceColumnCount = CGFloat(columnCount - 1)
let columnSpacing = delegate?.collectionView?(collectionView!, layout: self, minimumColumnSpacingFor: section) ?? minimumColumnSpacing

return floor((width - (spaceColumnCount * columnSpacing)) / CGFloat(columnCount))
}

override public func prepare() {
Expand Down