Skip to content
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

Add case for prefer-reduce-motion #4

Open
jyggiz opened this issue Jun 13, 2021 · 4 comments
Open

Add case for prefer-reduce-motion #4

jyggiz opened this issue Jun 13, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@jyggiz
Copy link

jyggiz commented Jun 13, 2021

I think it might be worth adding support for the prefer-reduce-motion media expression to disable animations if the user prefers not to see animations. We can add the preferReduceMotion property inside the second argument:

useTransitionController(refs.self, {
  registerTransitionController: true, 
  setupTransitionInTimeline: (timeline, elements, transitionContext) => {
     // Add your in timeline here.
   },
   setupTransitionOutTimeline: (timeline, elements, transitionContext) => {
      // Add your out timeline here. 
   },
   // Default value always is true
   preferReduceMotion: true   
}); 

What do you think about this implementation? I thought it would be nice to have support for such a feature in order to improve accessibility. I can create a PR for this.

@larsvanbraam
Copy link
Collaborator

I think this is a very good idea! 👍

But maybe change the default value of the preferReducedMotion to the window.matchMedia('(prefers-reduced-motion: reduce)').matches so it automatically picks up the user's preference.

Also, we should properly test this because disabling animations might break some event callbacks!

@larsvanbraam larsvanbraam added the enhancement New feature or request label Jun 14, 2021
@jyggiz
Copy link
Author

jyggiz commented Jun 14, 2021

I love the idea of ​​using window.matchMedia('(prefers-reduced-motion: reduce)').matches! I will start working on PR today!

@pigeonfresh
Copy link
Contributor

In some cases the transitionController is used for essential transitions (opening a menu e.g.) If we want to use transition controller for these types of animations we could perhaps opt for an alternative timeline. setupReducedTimelineIn or something like that

@ReneDrie
Copy link

ReneDrie commented Jun 14, 2021

In some cases the transitionController is used for essential transitions (opening a menu e.g.) If we want to use transition controller for these types of animations we could perhaps opt for an alternative timeline. setupReducedTimelineIn or something like that

I don't think this is needed, if you just set the preferReduceMotion option to false it should skip the prefers-reduced-motion check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants