From 73d13ba37b0a51b2eda83b22d186f7f096c999ab Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Fri, 8 Mar 2024 16:53:40 -0500 Subject: [PATCH] Pager should still hide on the empty condition. --- .../Atomic/Organisms/Carousel/Carousel.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 + } + } } //--------------------------------------------------