diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index 378289c7..80c55b16 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -247,7 +247,7 @@ open class Carousel: View { internal var _paginationDisplay: PaginationDisplay = .none internal var _paginationInset: CGFloat = UIDevice.isIPad ? VDSLayout.space3X : VDSLayout.space2X internal var _gutter: Gutter = UIDevice.isIPad ? .twentyFourPX : .twelvePX - internal var _peek: Peek = .none + internal var _peek: Peek = .standard internal var _numberOfSlides: Int = 1 private var _width: Width? = nil @@ -324,11 +324,17 @@ open class Carousel: View { carouselScrollBar.position = (carouselScrollBar.position == 0 || carouselScrollBar.position > carouselScrollBar.numberOfSlides) ? 1 : carouselScrollBar.position carouselScrollBar.isHidden = (totalPositions() <= 1) ? true : false - // When peek is set to ‘none,’ pagination controls are automatically set to persistent. + // Mobile/Tablet layouts without peek - must show pagination controls. + // If peek is ‘none’, pagination controls should show. So set to persistent. if peek == .none { paginationDisplay = .persistent } + // Minimum (Mobile only) Supported only on Mobile viewports. If a user passes Minimum for tablet carousel, the peek reverts to Standard. + if UIDevice.isIPad && peek == .minimum { + peek = .standard + } + containerViewHeightConstraint?.isActive = false containerStackHeightConstraint?.isActive = false updatePaginationControls() @@ -438,20 +444,26 @@ open class Carousel: View { func getSlotWidth() { let actualWidth = containerView.frame.size.width - minimumSlotWidth = actualWidth - (CGFloat(layout.value) * gutter.value) - switch peek { - case .standard: - // Supported for all Tablet viewports and layouts. - // Supported only for 1up layouts on Mobile viewports. - if UIDevice.isIPad { - minimumSlotWidth = minimumSlotWidth - (minimumSlotWidth/(CGFloat(layout.value) + 2)) - } else if layout == .oneUP { - minimumSlotWidth = minimumSlotWidth - (minimumSlotWidth/4) + let isScrollbarSuppressed = data.count > 0 && layout.value == data.count + let isPeekMinimumOnTablet = UIDevice.isIPad && peek == .minimum + let isPeekNone: Bool = peek == .none + minimumSlotWidth = isScrollbarSuppressed || isPeekMinimumOnTablet || isPeekNone ? actualWidth - ((CGFloat(layout.value)-1) * gutter.value): actualWidth - (CGFloat(layout.value) * gutter.value) + if !isScrollbarSuppressed { + switch peek { + case .standard: + // Standard(Default) Peek - Supported for all Tablet viewports and layouts. Supported only for 1up layouts on Mobile viewports. + if UIDevice.isIPad { + minimumSlotWidth = minimumSlotWidth - (minimumSlotWidth/(CGFloat(layout.value) + 3)) + } else if layout == .oneUP { + minimumSlotWidth = minimumSlotWidth - (minimumSlotWidth/4) + } + case .minimum: + // Peek Mimumum Width: 24px from edge of container (at the default view of the carousel with one peek visible) + // Minimum (Mobile only) Supported only on Mobile viewports. If a user passes Minimum for tablet carousel, the peek reverts to Standard. + minimumSlotWidth = isPeekMinimumOnTablet ? minimumSlotWidth : minimumSlotWidth - peekMinimum + case .none: + break } - case .minimum: - minimumSlotWidth = minimumSlotWidth - peekMinimum - case .none: - break } minimumSlotWidth = minimumSlotWidth / CGFloat(layout.value) }