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

[Showcase & Feat-Req] Disable or make subtle the parallax effect if "Reduce motion" accessibility is turned on #136

Open
ADTC opened this issue Mar 13, 2025 · 0 comments

Comments

@ADTC
Copy link

ADTC commented Mar 13, 2025

The parallax should only run in full motion if @media (prefers-reduced-motion: no-preference) is applicable. It should be disabled or have a reduced motion when the users prefers reduced motion; that is if @media (prefers-reduced-motion: reduce) is applicable.

macOS has an Accessibility toggle:

Image

Windows, Linux and other OSes have similar toggles which the browsers respect.

Showcase:

Currently I am able to achieve this using Javascript source code similar to this:

import SimpleParallax from 'simple-parallax-js/vanilla'

var images = document.querySelectorAll('img:not(.no-parallax)') // or as appropriate

const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches

new SimpleParallax(images, { scale: reduceMotion ? 1 : 1.5, /* other options */ })

Hint: Setting the scale to a slightly higher value than 1 will still keep the parallax effect but make it more subtle when reduced motion is enabled.

But a caveat: If the user toggles the "Reduce motion" toggle in the OS settings, a page reload is necessary to re-apply the above code. It maybe possible to achieve it using listeners, but I didn't explore it as the chances of a user toggling the option while viewing the page are minimal.

Feature Request:

I believe this should be baked into the library and applied by default without any developer configuration of the library.

Also, it should dynamically re-apply if the switch is toggled in OS settings. (Browsers automatically reapply CSS when it happens.)

An option could be added to control it more finely, such as having different options for when reduced motion is enabled.

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

No branches or pull requests

1 participant