-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Feature Request] Allow for Reduce Motion Accessibility #327
Comments
Great suggestion! Care to make a PR? |
Would love to, if I had time :( |
Generic starting point: let prefersReducedMotion: boolean;
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
prefersReducedMotion = mediaQuery.matches;
// to additionally track it over time, e.g. if user chooses to change this setting after initialization
mediaQuery.addEventListener('change', () => {
prefersReducedMotion = mediaQuery.matches;
}); Where "the rubber hits the road", within the if (this.duration > 0) {
this.determineDirectionAndSmartEasing();
this.paused = false;
this.rAF = requestAnimationFrame(this.count);
} else {
this.printValue(this.endVal);
} ... this would be a good place to check for Ideally it would also be checked in the following methods: Whoops, talking myself into throwing together a minimal PR, dang... |
@ggedde, on the off chance you enjoy writing tests, and you have time for it, I threw together a PR! 😆 |
Feature Request
CountUp.js version: 2.8.0
Description
When reduce motion is set by the device or browser, it might be good to not have countUp run and instead just show the end result. I think it may be best to just have this as default, but it could make some devs and users upset so adding an option would be best.
Something like:
true
disables animation no matter the device or browser settingauto
Looks at the device or browser setting. (Should be the default in next major release)false
Keeps animation no matter the device or browser setting, currently this is the default.Sure we can bypass this by wrapping countUp in a condition using our own code, but it would be really handy to not have to do that each time.
Thanks
The text was updated successfully, but these errors were encountered: