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

Support prefers-reduced-motion #8288

Closed
CharlesBelov opened this issue May 28, 2019 · 4 comments
Closed

Support prefers-reduced-motion #8288

CharlesBelov opened this issue May 28, 2019 · 4 comments

Comments

@CharlesBelov
Copy link

CharlesBelov commented May 28, 2019

Motivation

Please change your product so that prefers-reduced-motion is automatically supported. Specifically, if the browser indicates that the site visitor has specified that they don't want animation, flyTo, jumpTo, and easeTo would automatically not animate the transition, but simply display the new view. Chrome, Firefox, and Safari support this setting.
This is important because these effects can make some people, myself included, feel ill. That's probably not something you want associated with your product.

The advantage is that you can still provide animation for people who are not bothered by it without making people who are bothered by it feel ill.

Design Alternatives

This could be accommodated by querying the CSS media query prefers-reduced-motion. This is currently supported in Firefox, Chrome, and Safari.

The no-change option would be to expect websites to reduce animation for everyone or else leave people to learn to avoid a website if it makes them feel ill.

Design

Mock-Up

What will this design look like to developers?

The intent is that MapBox would implement this feature automatically so that developers do not need to be concerned with it.

What will this design look like to end users?

If an end user has set their operating system to reduce or eliminate animation, then maps will always go from one state to another with no movement transition.

If an end user has not set their operating system to reduce or eliminate animation, then maps will display with whatever movement transition the developer has programmed.

Concepts

How will we teach this design?

Since this would be implemented universally, no training would be needed. That said, you might link to an article on the subjects such as https://alistapart.com/article/designing-safer-web-animation-for-motion-sensitivity/ (warning: some people have reported that the image at the top of this article triggers symptoms similar to those caused by animation)

What terminology will work best for the new concepts introduced by this design?

vestibular disorders
prefers-reduced-motion

What existing precedents support the new concepts?

https://www.drupal.org home page detects prefers-reduced-motion in supporting browsers and either animates or not depending on that setting.

Where do the concepts set new precedents?

None, although this is an emerging best practice.

Implementation

How you would implement the design in Javascript?

If prefers-reduced-motion is set to reduce,
then transition between two map states without animation.

How you would implement the design in C++?

Same pseudocode.

What parts of the Mapbox GL ecosystem will need to change to accommodate this design?

flyTo, jumpTo, and easeTo

Are there any important edge cases?

There is disagreement on how to handle browsers which do not support prefers-reduced-motion, such as IE or Edge. Some recommend treating such browsers as requesting no animation; some provide the animation.

@andrewharvey
Copy link
Collaborator

I'm slightly in favour of GL JS handling this so developers don't need to write a whole bunch of special cases. If someone has configured their browser to prefer reduced motion, we should respect that by default.

https://developers.google.com/web/updates/2019/03/prefers-reduced-motion shows how to detect this setting via a standard API with JavaScript.

  • jumpTo should already be unanimated, it should just be flyTo, easeTo, panBy
  • map.fadeDuration (fade-in/fade-out animation for label collisions)
  • runtime styling transitions/cross-fading

@mourner
Copy link
Member

mourner commented May 29, 2019

I agree we should support this. In camera.js, there are a few instances were we hardcode the default duration (either 500ms for easeTo, 1000ms for resetNorth, and duration based on fly length in flyTo) — we should set those to 0 if window.matchMedia('(prefers-reduced-motion)').matches === false.

Not sure about fadeDuration@CharlesBelov is this considered motion too? Labels appearing/disappearing abruptly might look worse for people sensitive to this...

@CharlesBelov
Copy link
Author

CharlesBelov commented May 29, 2019

I believe fadeDuration is as separate issue. For me, personally, the abrupt appearing/disappearing is usually problematic when triggered accidentally without intent, as in cursoring over something while on the way to something else or overshooting my target; it's best if there is a delay until intent is established (again, outside the current issue). That said, I'm not aware of major discussions on fading or not fading in association with prefers-reduced-motion; though it has come up from time to time.

@1ec5
Copy link
Contributor

1ec5 commented Jul 19, 2019

Fixed in #8494. mapbox/mapbox-gl-native#15187 tracks implementing the same feature on iOS.

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

No branches or pull requests

4 participants