final carousel fixes
This commit is contained in:
parent
7441968f41
commit
b1ff5b2a64
@ -41,7 +41,7 @@ open class Carousel: View {
|
|||||||
open var numberOfPages = 0
|
open var numberOfPages = 0
|
||||||
|
|
||||||
/// The models for the molecules.
|
/// The models for the molecules.
|
||||||
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]?
|
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]?
|
||||||
|
|
||||||
/// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%.
|
/// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%.
|
||||||
public var itemAlignment = UICollectionView.ScrollPosition.left
|
public var itemAlignment = UICollectionView.ScrollPosition.left
|
||||||
@ -79,6 +79,7 @@ open class Carousel: View {
|
|||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.layoutCollection()
|
self.layoutCollection()
|
||||||
}
|
}
|
||||||
|
collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invalidates the layout and ensures we are paged to the correct cell.
|
/// Invalidates the layout and ensures we are paged to the correct cell.
|
||||||
@ -398,6 +399,11 @@ extension Carousel: UICollectionViewDelegateFlowLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Carousel: UICollectionViewDataSource {
|
extension Carousel: UICollectionViewDataSource {
|
||||||
|
|
||||||
|
open func numberOfSections(in collectionView: UICollectionView) -> Int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||||
return molecules?.count ?? 0
|
return molecules?.count ?? 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]
|
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]
|
||||||
public var index: Int = 0
|
public var index: Int = 0
|
||||||
public var spacing: CGFloat?
|
public var spacing: CGFloat?
|
||||||
public var border: Bool?
|
public var border: Bool?
|
||||||
@ -41,7 +41,7 @@ import UIKit
|
|||||||
public var selectable = false
|
public var selectable = false
|
||||||
public var selectedIndex: Int?
|
public var selectedIndex: Int?
|
||||||
|
|
||||||
public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) {
|
public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]) {
|
||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user