From 4dec2388ae6b45e0550edfa4b3e814a278614b45 Mon Sep 17 00:00:00 2001 From: Nandhini Rajendran Date: Mon, 21 Oct 2024 23:07:48 +0530 Subject: [PATCH] Bugfix CXTDT-619833 - pagination fix --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 58ad2280..03480a1c 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -111,7 +111,9 @@ open class Carousel: View { /// Updates if the pager is visible or not. private func updatePagerVisibility() { guard let pagingView = pagingView else { return } - let shouldHidePager = collectionView.contentSize.width < bounds.width + // Consider hidesForSinglePage only if numberOfPages is less than 2 + let hidePager = (numberOfPages < 2) ? ((pagingView.model as? CarouselPagingModelProtocol)?.hidesForSinglePage ?? true) : false + let shouldHidePager = (collectionView.contentSize.width < bounds.width) && hidePager if (shouldHidePager && !pagingView.isHidden) || (!shouldHidePager && pagingView.isHidden) { pagingView.isHidden = shouldHidePager pagingBottomPin?.isActive = !shouldHidePager @@ -491,6 +493,7 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex + pagingView?.currentIndex = adjustedIndex } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil)