Merge branch 'bugfix/carousel_index' into 'develop'
height and loop fix See merge request BPHV_MIPS/mvm_core_ui!577
This commit is contained in:
commit
6b7c541bf1
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user