status observer for accessibility changes
This commit is contained in:
parent
4469387e4d
commit
a18152f6b9
@ -114,6 +114,9 @@ open class Carousel: View {
|
|||||||
if UIAccessibility.isVoiceOverRunning {
|
if UIAccessibility.isVoiceOverRunning {
|
||||||
collectionView.isScrollEnabled = false
|
collectionView.isScrollEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Listen for accessibility changes
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(accessibilityStatusChanged(_:)), name: UIAccessibility.voiceOverStatusDidChangeNotification, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
@ -191,6 +194,8 @@ open class Carousel: View {
|
|||||||
|
|
||||||
molecules?.insert(contentsOf: newMolecules.suffix(2), at: 0)
|
molecules?.insert(contentsOf: newMolecules.suffix(2), at: 0)
|
||||||
molecules?.append(contentsOf: newMolecules.prefix(2))
|
molecules?.append(contentsOf: newMolecules.prefix(2))
|
||||||
|
} else {
|
||||||
|
loop = false
|
||||||
}
|
}
|
||||||
|
|
||||||
pageIndex = 0
|
pageIndex = 0
|
||||||
@ -306,6 +311,15 @@ open class Carousel: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resets view
|
||||||
|
@objc private func accessibilityStatusChanged(_ sender: Notification) {
|
||||||
|
// Fixes defects where it scrolls when it shouldn't with voiceover
|
||||||
|
collectionView.isScrollEnabled = !UIAccessibility.isVoiceOverRunning
|
||||||
|
if let model = model {
|
||||||
|
set(with: model, delegateObject, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Accessibility element that allows for adjustable carousel.
|
/// Accessibility element that allows for adjustable carousel.
|
||||||
private var carouselAccessibilityElement: CarouselAccessibilityElement?
|
private var carouselAccessibilityElement: CarouselAccessibilityElement?
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user