-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[a11y] Check for reduced motion frame names #2451
Conversation
- brings parity to the android for the changes in iOS github.com/airbnb/lottie-ios/pull/2110
setFrame((int) (getSpeed() < 0 ? getMinFrame() : getMaxFrame())); | ||
Marker markerForAnimationsDisabled = getMarkerForAnimationsDisabled(); | ||
if (markerForAnimationsDisabled != null) { | ||
setFrame((int) markerForAnimationsDisabled.startFrame); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On iOS we also support reduced motion markers with both a start frame and an end frame. If the marker provides an end frame, we play the animation from the start / end of the reduced motion marker as opposed to just only displaying the first frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calda Thanks for the quick reply, Is there a way to play from the start to end frame? Sorry for not knowing from looking at this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gpeal should be able to help :) just giving my drive-by review from an iOS perspective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -794,14 +795,52 @@ public void playAnimation() { | |||
} | |||
} | |||
if (!animationsEnabled()) { | |||
setFrame((int) (getSpeed() < 0 ? getMinFrame() : getMaxFrame())); | |||
Marker markerForAnimationsDisabled = getMarkerForAnimationsDisabled(); | |||
if (markerForAnimationsDisabled != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should determine if "reduced motion" mode is enabled? Reading the code it seems like the reduced motion marker is always used if present, as opposed to only using it when the app / OS "reduced motion" toggle is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calda It seems odd that we don't check to see if the animations are disabled in accessibility settings, it seems like it is set by the consumer application with: https://github.com/airbnb/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java#L1190
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It defaults to this which can be set if battery saver is on or if you turn off animations in developer settings. It's not an a11y setting on Android afaik though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, I missed that this is gated by a animationsEnabled()
check, which can be configured via setSystemAnimationsAreEnabled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't feel quite right to take a specific a11y setting on iOS and use the same name on Android when it maps to different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gpeal In the a11y community, "reduced motion" is the more common term even if it comes from Apple. I think the same is applied to lottie-web as well, so designers can produce one asset to share across platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's reasonable. It's worth noting that this would affect non a11y use cases like battery saver and developer settings but this behavior may still be better if the designer was explicit about it.
Could you:
- Double check that the utils function I linked to returns 0 for animation scale when this a11y setting is enabled
- Add documentation for
setSystemAnimationsAreEnabled
in case anybody else calls it so they can learn about this without reading the source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation for setSystemAnimationsAreEnabled in case anybody else calls it so they can learn about this without reading the source?
I added the document comment, thanks for the suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Looks great from an iOS perspective, especially after adding support for markers with an end frame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. I also raised this with the lottie spec team and they created lottie/lottie-spec#7 for visibility and awareness for other platforms.
If you want to create a ReducedMotionTestCase, that would be great 😄 |
@gpeal I think I added the test case that might work. Wasn't able to run locally, but we will see with the workflow here. |
Could you apply this patch to fix the test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one small last comment
Co-authored-by: Gabriel Peal <gpeal@users.noreply.github.com>
Brings parity to the android for the changes in iOS airbnb/lottie-ios/pull/2110
This PR adds support for respecting the system "reduction motion" option.
Animations Enabled
screen-20240122-155931.mp4
Animations Disabled
screen-20240122-160034.mp4