height and loop fix
This commit is contained in:
parent
8187c36a81
commit
176944f2a0
@ -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