fixes for pager
This commit is contained in:
parent
2052e4ddc6
commit
f9a57f5fe5
@ -88,7 +88,7 @@ open class Carousel: View {
|
||||
|
||||
// Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled.
|
||||
guard let model = model as? CarouselModel,
|
||||
(model.paging == true || model.loop == true) else { return }
|
||||
(model.paging == true || loop == true) else { return }
|
||||
DispatchQueue.main.async {
|
||||
self.collectionView.scrollToItem(at: IndexPath(row: self.currentIndex, section: 0), at: self.itemAlignment, animated: false)
|
||||
self.collectionView.layoutIfNeeded()
|
||||
@ -108,6 +108,11 @@ open class Carousel: View {
|
||||
bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint
|
||||
collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300)
|
||||
collectionViewHeight?.isActive = true
|
||||
|
||||
// Fixes defects where it scrolls when it shouldn't with voiceover
|
||||
if UIAccessibility.isVoiceOverRunning {
|
||||
collectionView.isScrollEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
@ -382,6 +387,11 @@ extension Carousel: UIScrollViewDelegate {
|
||||
setAccessiblity(collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)), index: index)
|
||||
UIAccessibility.post(notification: .layoutChanged, argument: cell)
|
||||
}
|
||||
|
||||
// Force call if no animation
|
||||
if !animated {
|
||||
scrollViewDidEndScrollingAnimation(collectionView)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adjusts the current contentOffset if we are going onto buffer cells while looping to help with the endless scrolling appearance.
|
||||
@ -407,8 +417,7 @@ extension Carousel: UIScrollViewDelegate {
|
||||
open func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
|
||||
// Adjust for looping
|
||||
if let model = model as? CarouselModel,
|
||||
model.loop == true {
|
||||
if loop == true {
|
||||
adjustOffsetForLooping(scrollView)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user