diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index a9fcc040..0328e1ff 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -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 + } + } } //--------------------------------------------------