Pager should still hide on the empty condition.

This commit is contained in:
Hedden, Kyle Matthew 2024-03-08 16:53:40 -05:00
parent 2877534c70
commit 73d13ba37b

View File

@ -96,12 +96,6 @@ open class Carousel: View {
collectionView.scrollToItem(at: IndexPath(row: currentIndex, section: 0), at: itemAlignment, animated: false)
collectionView.layoutIfNeeded()
showPeaking(true)
let shouldHidePager = model.molecules.isEmpty || collectionView.contentSize.width < bounds.width
if let pagingView = pagingView, shouldHidePager != pagingView.isHidden {
pagingView.isHidden = shouldHidePager
pagingBottomPin?.isActive = !shouldHidePager
}
}
}
@ -146,6 +140,15 @@ open class Carousel: View {
(cell as? MVMCoreViewProtocol)?.updateView(size)
}
layoutCollection()
// Check must be dispatched to main for the layout to complete in layoutCollection.
DispatchQueue.main.async { [self] in
let shouldHidePager = molecules?.isEmpty ?? true || collectionView.contentSize.width < bounds.width
if let pagingView = pagingView, shouldHidePager != pagingView.isHidden {
pagingView.isHidden = shouldHidePager
pagingBottomPin?.isActive = !shouldHidePager
}
}
}
//--------------------------------------------------