From f13451ea37fb80aea10823fc4b86eb1ce42b2303 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 1 Jul 2024 15:03:00 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-7013 story: Standard Peek supported for all Tablet viewports and layouts and for 1up layouts on Mobile viewports only. --- VDS/Components/Carousel/Carousel.swift | 46 +++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index e461bc99..0347efc0 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -358,10 +358,34 @@ open class Carousel: View { if UIDevice.isIPad && peek == .minimum { peek = .standard } + + // Standard(Default) Peek - Supported for all Tablet viewports and layouts. Supported only for 1up layouts on Mobile viewports. + if peek == .standard && !UIDevice.isIPad && layout != CarouselScrollbar.Layout.oneUP { + peek = .minimum + } updatePaginationControls() getSlotWidth() - + addCarouselSlots() + } + + open override func reset() { + super.reset() + shouldUpdateView = false + aspectRatio = .none + layout = UIDevice.isIPad ? .threeUP : .oneUP + pagination = .init(kind: .lowContrast, floating: true) + paginationDisplay = .none + paginationInset = UIDevice.isIPad ? VDSLayout.space3X : VDSLayout.space2X + gutter = UIDevice.isIPad ? .twentyFourPX : .twelvePX + peek = .standard + width = nil + } + + //-------------------------------------------------- + // MARK: - Private Methods + //-------------------------------------------------- + private func addCarouselSlots() { if containerView.frame.size.width > 0 { containerViewHeightConstraint?.isActive = false containerStackHeightConstraint?.isActive = false @@ -408,22 +432,6 @@ open class Carousel: View { } } - open override func reset() { - super.reset() - shouldUpdateView = false - aspectRatio = .none - layout = UIDevice.isIPad ? .threeUP : .oneUP - pagination = .init(kind: .lowContrast, floating: true) - paginationDisplay = .none - paginationInset = UIDevice.isIPad ? VDSLayout.space3X : VDSLayout.space2X - gutter = UIDevice.isIPad ? .twentyFourPX : .twelvePX - peek = .standard - width = nil - } - - //-------------------------------------------------- - // MARK: - Private Methods - //-------------------------------------------------- private func ratioSize(for width: CGFloat) -> CGSize { var height: CGFloat = width @@ -543,10 +551,10 @@ open class Carousel: View { func updateScrollPosition(position: Int, callbackText: String) { if carouselScrollBar.numberOfSlides > 0 { - let contentOffsetWidth = scrollView.contentSize.width + let scrollContentSizeWidth = scrollView.contentSize.width let totalPositions = totalPositions() let multiplier: Float = (position == 1) ? 0 : Float((position)-1) / Float(totalPositions) - let xPos = (position == totalPositions) ? (contentOffsetWidth - containerView.frame.size.width) : CGFloat(Float(contentOffsetWidth) * multiplier) + let xPos = (position == totalPositions) ? (scrollContentSizeWidth - containerView.frame.size.width) : CGFloat(Float(scrollContentSizeWidth) * multiplier) carouselScrollBar.scrubberId = position let yPos = scrollView.contentOffset.y scrollView.setContentOffset(CGPoint(x: xPos, y: yPos), animated: true)