diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 6cc67d4e..1abab6e0 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -50,7 +50,7 @@ open class Carousel: View { /// From 0-1. The item width as a percent of the carousel width. public var itemWidthPercent: CGFloat = 1 - /// The height of the carousel. Default is 300. + /// The height of the carousel. public var collectionViewHeight: NSLayoutConstraint? /// The view that we use for paging @@ -162,6 +162,9 @@ open class Carousel: View { if let height = carouselModel.height { collectionViewHeight?.constant = height + collectionViewHeight?.isActive = true + } else { + collectionViewHeight?.isActive = false } registerCells(with: carouselModel, delegateObject: delegateObject) @@ -492,12 +495,12 @@ extension Carousel: UIScrollViewDelegate { } // If we are swiping to a buffer cell, change to real cell before beginning animation so we don't go out of bounds. - if cellToSwipeTo < 2 { + if loop, cellToSwipeTo < 2 { let newOffset = scrollView.contentOffset.x + (width * CGFloat(numberOfPages)) scrollView.contentOffset.x = newOffset targetContentOffset.pointee.x = newOffset cellToSwipeTo = cellToSwipeTo + numberOfPages - } else if cellToSwipeTo > numberOfPages + 1 { + } else if loop, cellToSwipeTo > numberOfPages + 1 { let newOffset = scrollView.contentOffset.x - (width * CGFloat(numberOfPages)) scrollView.contentOffset.x = newOffset targetContentOffset.pointee.x = newOffset