You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This rule aims to ensure that developers write animations in SwiftUI while taking into account the user’s “Reduce Motion” accessibility settings. The “Reduce Motion” setting is an accessibility feature that minimizes the animations and transitions on the screen for users who are sensitive to motion.
Ensure SwiftUI animations respect the user’s “Reduce Motion” accessibility setting.
Rule justification
Ignoring the “Reduce Motion” setting can lead to an uncomfortable user experience for those sensitive to motion and in the worst-case scenario, some users might no longer be able to use your application.
Severity: high.
Ignoring this setting can degrade the user experience, but it does not make the application unusable.
Remediation Cost: easy.
It only requires adding a condition to animations to respect the “Reduce Motion” setting.
Implementation principle
During the static analysis of the source code, we will need to detect instances where Animation is used without the @Environment(\.accessibilityReduceMotion) var reduceMotion modifier and animation(reduceMotion ? nil : .spring()).
Rule title
Respecting “Reduce Motion” Accessibility Settings in SwiftUI Animations
Language and platform
Swift (5.3+), SwiftUI (iOS 13+, macOS 10.15+, tvOS 13+, watchOS 6+, visionOS 1+)
Rule description
This rule aims to ensure that developers write animations in SwiftUI while taking into account the user’s “Reduce Motion” accessibility settings. The “Reduce Motion” setting is an accessibility feature that minimizes the animations and transitions on the screen for users who are sensitive to motion.
Bad example
Good example
how-to-detect-the-reduce-motion-accessibility-setting-1.mp4
Rule short description
Ensure SwiftUI animations respect the user’s “Reduce Motion” accessibility setting.
Rule justification
Ignoring the “Reduce Motion” setting can lead to an uncomfortable user experience for those sensitive to motion and in the worst-case scenario, some users might no longer be able to use your application.
(https://accessibilite.numerique.gouv.fr/methode/criteres-et-tests/#13.7)[RGAA Rule 13.7]
(https://accessibilite.numerique.gouv.fr/methode/criteres-et-tests/#13.8)[RGAA Rule 13.8]
Severity / Remediation Cost
Severity: high.
Ignoring this setting can degrade the user experience, but it does not make the application unusable.
Remediation Cost: easy.
It only requires adding a condition to animations to respect the “Reduce Motion” setting.
Implementation principle
During the static analysis of the source code, we will need to detect instances where Animation is used without the @Environment(\.accessibilityReduceMotion) var reduceMotion modifier and animation(reduceMotion ? nil : .spring()).
Source video & code
Paul Hudson @twostraws December 1st 2022
https://www.hackingwithswift.com/quick-start/swiftui/how-to-detect-the-reduce-motion-accessibility-setting
The text was updated successfully, but these errors were encountered: