pagination, model and reset fixes

This commit is contained in:
Khan, Arshad 2021-07-08 01:50:49 +05:30
parent b67d63c159
commit 7441968f41
3 changed files with 19 additions and 0 deletions

View File

@ -234,6 +234,7 @@ open class BarsIndicatorView: CarouselIndicator {
super.reset()
barReferences.forEach { $0.removeFromSuperview() }
barReferences = []
currentIndex = 0
}
public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) {

View File

@ -248,4 +248,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
bottomConstraint?.constant = constant
topConstraint?.constant = constant
}
open override func reset() {
super.reset()
currentIndex = 0
previousIndex = 0
}
}

View File

@ -177,6 +177,7 @@ open class Carousel: View {
if let selectedIndex = carouselModel.selectedIndex {
let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex
collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: [])
goTo(adjustedIndex, animated: false)
}
}
@ -207,6 +208,13 @@ open class Carousel: View {
pageIndex = 0
}
open override func reset() {
super.reset()
currentIndex = 0
pageIndex = 0
pagingView?.reset()
}
var pagingMoleculeName: String?
/// Sets up the paging molecule
@ -425,6 +433,10 @@ extension Carousel: UICollectionViewDelegate {
adjustedIndex = adjustedIndex + numberOfPages
}
model.selectedIndex = adjustedIndex
currentIndex = adjustedIndex
pageIndex = currentIndex
pagingView?.currentIndex = adjustedIndex
updateModelIndex()
}
if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol {
cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil)