diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 4fb7b413..6cc67d4e 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -114,6 +114,9 @@ open class Carousel: View { if UIAccessibility.isVoiceOverRunning { 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) { @@ -191,6 +194,8 @@ open class Carousel: View { molecules?.insert(contentsOf: newMolecules.suffix(2), at: 0) molecules?.append(contentsOf: newMolecules.prefix(2)) + } else { + loop = false } 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. private var carouselAccessibilityElement: CarouselAccessibilityElement?