diff --git a/Example/InfiniteLayout/CustomViewController.swift b/Example/InfiniteLayout/CustomViewController.swift index 1c2d8ef..7ace70d 100644 --- a/Example/InfiniteLayout/CustomViewController.swift +++ b/Example/InfiniteLayout/CustomViewController.swift @@ -12,6 +12,7 @@ import InfiniteLayout class CustomViewController: UIViewController { @IBOutlet weak var infiniteCollectionView: InfiniteCollectionView! + } extension CustomViewController: UICollectionViewDataSource { diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 7c242e3..dbe2213 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,12 +1,12 @@ PODS: - CocoaProxy (0.1.1) - Differentiator (3.0.2) - - InfiniteLayout (0.2.3.1): + - InfiniteLayout (0.2.3.4): - CocoaProxy (~> 0) - - InfiniteLayout/Core (= 0.2.3.1) - - InfiniteLayout/Core (0.2.3.1): + - InfiniteLayout/Core (= 0.2.3.4) + - InfiniteLayout/Core (0.2.3.4): - CocoaProxy (~> 0) - - InfiniteLayout/Rx (0.2.3.1): + - InfiniteLayout/Rx (0.2.3.4): - CocoaProxy (~> 0) - InfiniteLayout/Core (~> 0) - RxCocoa (~> 4) @@ -39,7 +39,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CocoaProxy: 35ab81e24325b33834cffe45a3d1fd48ca67ef3a Differentiator: a87be69eba49ec4ab460c7671143ee3a9eececfd - InfiniteLayout: 17bbab705aa4d941fa82a7e9b658c96d13ce91a3 + InfiniteLayout: 01f4d7bda9e2c5be476f10c670a02460e8568964 RxCocoa: cc1fec49cdc8fabe645964de7c51c099a36c2aa8 RxDataSources: cb7c31e652a87ebb919da45f716bbb87b3765f6b RxSwift: 4219941c1244c88002901bd87a69d3aea9ae71f0 diff --git a/InfiniteLayout/Classes/InfiniteCollectionView.swift b/InfiniteLayout/Classes/InfiniteCollectionView.swift index 3261a1d..a1d3171 100644 --- a/InfiniteLayout/Classes/InfiniteCollectionView.swift +++ b/InfiniteLayout/Classes/InfiniteCollectionView.swift @@ -134,7 +134,7 @@ extension InfiniteCollectionView: UICollectionViewDataSource { } private var multiplier: Int { - return InfiniteDataSources.multiplier(estimatedItemSize: self.infiniteLayout.itemSize) + return InfiniteDataSources.multiplier(estimatedItemSize: self.infiniteLayout.itemSize, enabled: self.infiniteLayout.isEnabled) } public func section(from infiniteSection: Int) -> Int { diff --git a/InfiniteLayout/Classes/InfiniteDataSource.swift b/InfiniteLayout/Classes/InfiniteDataSource.swift index e9202c9..9a7db36 100644 --- a/InfiniteLayout/Classes/InfiniteDataSource.swift +++ b/InfiniteLayout/Classes/InfiniteDataSource.swift @@ -17,7 +17,10 @@ class InfiniteDataSources { return IndexPath(item: infiniteIndexPath.item % numberOfItems, section: self.section(from: infiniteIndexPath.section, numberOfSections: numberOfSections)) } - static func multiplier(estimatedItemSize: CGSize) -> Int { + static func multiplier(estimatedItemSize: CGSize, enabled: Bool) -> Int { + guard enabled else { + return 1 + } let min = Swift.min(estimatedItemSize.width, estimatedItemSize.height) let count = ceil(InfiniteLayout.minimumContentSize / min) return Int(count) diff --git a/InfiniteLayout/Classes/InfiniteLayout.swift b/InfiniteLayout/Classes/InfiniteLayout.swift index 0a53ba4..cda2139 100644 --- a/InfiniteLayout/Classes/InfiniteLayout.swift +++ b/InfiniteLayout/Classes/InfiniteLayout.swift @@ -67,7 +67,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout { override open var collectionViewContentSize: CGSize { guard hasValidLayout else { - return super.collectionViewContentSize + return self.contentSize } return CGSize(width: scrollDirection == .horizontal ? self.contentSize.width * multiplier : self.contentSize.width, height: scrollDirection == .vertical ? self.contentSize.height * multiplier : self.contentSize.height) diff --git a/InfiniteLayout/Rx/RxInfiniteCollectionViewDataSource.swift b/InfiniteLayout/Rx/RxInfiniteCollectionViewDataSource.swift index 22091d0..4cfbd98 100644 --- a/InfiniteLayout/Rx/RxInfiniteCollectionViewDataSource.swift +++ b/InfiniteLayout/Rx/RxInfiniteCollectionViewDataSource.swift @@ -9,6 +9,8 @@ import UIKit import RxDataSources open class RxInfiniteCollectionViewSectionedReloadDataSource: RxCollectionViewSectionedReloadDataSource { + + public var isEnabled: Bool = true open override subscript(section: Int) -> S { let section = InfiniteDataSources.section(from: section, numberOfSections: sectionModels.count) @@ -33,7 +35,7 @@ open class RxInfiniteCollectionViewSectionedReloadDataSource Int { @@ -54,6 +56,8 @@ open class RxInfiniteCollectionViewSectionedReloadDataSource: RxCollectionViewSectionedAnimatedDataSource { + public var isEnabled: Bool = true + open override subscript(section: Int) -> S { let section = InfiniteDataSources.section(from: section, numberOfSections: sectionModels.count) return self.sectionModels[section] @@ -77,7 +81,7 @@ open class RxInfiniteCollectionViewSectionedAnimatedDataSource Int {