Re: [w3ctag/design-reviews] CSS Animation Worklet API (#349)

Thanks for the considered response! The code examples are really well thought through to demonstrate different strategies for handling `prefers-reduced-motion` options.

Regarding `matchMedia()` and the possibility of having a first-class API to detect a `prefers-reduced-motion` state, I don't know that having an existing generic API is necessarily a sufficient argument against having a dedicated API, particularly when media queries are designed primarily to be used from CSS code, not JavaScript. 

Indeed, much of what can be done with Web Animations can be done with CSS, as I understand it - in theory you could probably construct an animation in JS by building CSS strings and setting appropriate attributes, but that is inconvenient and error-prone.

Your two code examples interestingly use opposite strategies (as I'm sure you're aware): one detects a *lack of* user preference, while the other detects a `reduce` preference. This seems like a good example of the extra cognitive load involved in using `matchMedia()` - you need to be able to construct the media query and understand the result. A first class API would remove that cognitive load.

I wouldn't consider this a blocking issue for AnimationWorklet, especially since Web Animations does share the same issue (as you allude to), but it would be nice to consider a first-class API (or small set of APIs) for detecting `prefers-reduced-motion: reduce` which may be used in either context. I believe this would encourage authors to consider this case more often. 

For example, one starting point might be to consider the two strategies in your code examples:
- allow setting a secondary effect on an `Animation` to be used if a user prefers reduced motion
- allow an author to opt in to using a single static keyframe if a user prefers reduced motion

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/349#issuecomment-507509382

Received on Tuesday, 2 July 2019 04:04:06 UTC