Olivero has a lot of animations. It would be good to support users who prefer to turn animations off.

Ensure the designs can work without animations, i.e. they don't rely on animation to convey information or state. Drop-downs, focus states, etc, can appear instantaneously and still be effective.

Use a CSS media query and/or matchMedia() check for prefers-reduced-motion, only animate things if the user permits it.

How to disable animation in various hardware and OS'es: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-...

Issue fork drupal-3093461

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andrewmacpherson created an issue. See original summary.

fhaeberle’s picture

+1 this would be really helpful, because oliveros design comes with a lot of animation of critical elements like nav (which is great, but not for all).

It would be good to support users who prefer to turn animations off.

To give a bit more context: Some users experience distraction or nausea from animated content. For example, if scrolling a page causes elements to move other than the essential movement associated with scrolling—as with parallax scrolling, where backgrounds move at a different rate to foregrounds—it can trigger vestibular disorders. Vestibular (inner ear) disorder reactions include dizziness, nausea and headaches. The impact of animation on people with vestibular disorders can be quite severe. Triggered reactions include nausea, migraine headaches, and potentially needing bed rest to recover. src

mherchel’s picture

This should be relatively straightforward to implement, however my understanding was that prefers-reduced-motion was for larger more intrusive animations. According to https://developers.google.com/web/updates/2019/03/prefers-reduced-motion, this is meant for "parallax scrolling, zooming effects, etc."

Olivero's animations help with usability, as they indicate where the element has originated from. For example, the desktop navbar slides out when hitting the nav button -- this indicates its origin to the end user. The dropdown buttons also have a slight 10px slide-down/opacity effect, which also gives an indication.

If we disable this on prefers-reduced-motion, these users would lose this benefit. Note that it's "reduced" motion, not any motion.

The most complete article I can find on the subject is https://webkit.org/blog/7551/responsive-design-for-motion/

The perceptual utility of appropriate, functional motion can increase the understandability and —yes— accessibility of a user interface. There are numerous articles on the benefits of animation to increase user engagement:

Consider each animation in its context. If you determine a specific animation is likely to be a vestibular trigger, consider serving an alternate, simpler animation, or display another visual indicator to convey the intended meaning.

Thoughts?

andrewmacpherson’s picture

however my understanding was that prefers-reduced-motion was for larger more intrusive animations.

Meh. The problem is that there is NO way to test that. In any case, Olivero's animation is on the large and loud side:

  • The vertical menu takes up 1/3 of a 1190px viewport, and a greater proportion as the viewport gets narrower.
  • The magically disappearing/reappearing horizontal menu affects the entire width of the viewport. More importantly, it moves in a direction perpendicular to the vertical scrolling which triggers it.

If we disable this on prefers-reduced-motion, these users would lose this benefit. Note that it's "reduced" motion, not any motion.

A big problem is that the media query's name doesn't match user expectations, based on the name of the user preference which controls it. To a developer it's "prefers-reduced-motion", but to most users (going by the labels in their OS-level preferences) it's called "remove".

Rough history of the feature:

  1. Windows 7 introduced some settings to remove animations. This removes (not "reduce") animations in the Windows UI. At the time, it had no effect on browser content.
  2. iOS 8(?) came out, with lots of motion, and Apple came in for lots of criticism.
  3. Apple introduce an OS-level setting called "reduce motion".
  4. Apple add a media query to Safari, and take it to the CSS standards track.
  5. Firefox implement the media query. On macOS and iOS, they tie it to the "prefer reduced motion" setting. On Windows they tie it to the existing "remove" animations setting. On Android, they tie it to the "remove animations" setting introduced in Android 9.
  6. Chrome did the same as Firefox.

Upshot: on Apple devices, users are told it will "reduce" animation (but not how much; it's vague). On Windows and Android, they are told it will remove animation. So it's better to turn off all animations, because that's what the majority of users are told will happen when they choose the user setting.

There is no use in telling people that animation benefits them, when they have said they don't want it.

andrewmacpherson’s picture

Implementation-wise, I recommend using a single media query and global selector to disable all animation. The idea is that this will be more robust than having to add specific overrides for individual components.

The rationale is basically the same as for underlining links by default in #3094464: Make link underlines more robust in Olivero CSS. It can catch any animations which contrib modules have added.

We'll be recommending this approach in #2928103: [policy, no patch] Use "prefers-reduced-motion" media query to disable animations. There's a sample CSS rule in comment #23 there, but there are other approaches. One interesting one is to use a duration of 1ms so animations complete quicker than the human eye can tell.

mherchel’s picture

I can foresee transition: none !important being problematic because it doesn't ever fire the transitionend event.

I've seen examples where you set transition-duration: 0.01s;. This would still obviously still fire the transitionend event.

I'll chime in on the core issue as well.

andrewmacpherson’s picture

Yes, I agree about the short-duration approach, to preserve transition events firing. From what I've learned so far, that's a sensible approach. I've said more on the animation core policy issue.

ellenoise’s picture

What is the best place to display the enable/disable button, so that it is always available?

Would it make more sense for the animations to initialize as enabled, or disabled?

andrewmacpherson’s picture

@ellenoise - we don't need button to enable/disable animations; I think it will suffice to build it into the stylesheet using the media query. The idea is that Olivero will respect a user's operating system preferences.

ellenoise’s picture

Here is a Pull Request for this issue: https://github.com/Lullabot/olivero-poc/pull/26

While testing on Google Chrome, I noticed that the hamburger icon in the sidebar nav still animates. When clicked, it will transform from three horizontal lines, into an "X". Is that animation a concern, or not because of its size?

andrewmacpherson’s picture

It's better to remove all animations when the user prefers reduced motion. This one might seem minor, but why risk it.

What method does the hamburger icon use to achieve the animation?

andrewmacpherson’s picture

Status: Active » Needs work

Re #11. The pull request uses animation: none !important to remove the animations.

There's a better approach, which uses a very small animation-duration which is too fast for a human to notice. The advantage to this is that JS animation events still fire, so that makes the JS easier to maintain.

We've discussed this in the core animation policy issue at #2928103-52: [policy, no patch] Use "prefers-reduced-motion" media query to disable animations (starting at comment 52). I think there's a consensus that we'll recommend the "tiny duration" approach for Drupal core themes. The technique is also being used by the mozdevs/CSSRemedy library, and is discussed in depth at https://github.com/mozdevs/cssremedy/issues/11.

ellenoise’s picture

Thanks for all the helpful resources!

I updated the PR with this snippet, using the tiny duration approach:

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after {
    animation-duration: 0.001s !important;
    -webkit-animation-duration: 0.001s !important;
    -moz-animation-duration: 0.001s !important;
    -o-animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
    -webkit-transition-duration: 0.001s !important;
    -moz-transition-duration: 0.001s !important;
    -ms-transition-duration: 0.001s !important;
    -o-transition-duration: 0.001s !important;
  }
}

The hamburger icon uses the same method for animation as the other elements on the page, but it was missed because it was made of :before and :after pseudo elements. Using this selector, I was able to account for that case: `*, *:before, *:after`

Vendor prefixes are based on MDN's documentation for "transition-duration" and "animation-duration".

ellenoise’s picture

Status: Needs work » Needs review
ressa’s picture

How would a themer using Olivero as base theme turn animations off? Would this do the job?

@media {
  *, *:before, *:after {
    animation-duration: 0.001s !important;
    -webkit-animation-duration: 0.001s !important;
    -moz-animation-duration: 0.001s !important;
    -o-animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
    -webkit-transition-duration: 0.001s !important;
    -moz-transition-duration: 0.001s !important;
    -ms-transition-duration: 0.001s !important;
    -o-transition-duration: 0.001s !important;
  }
}
mherchel’s picture

My initial thought on this is that we should do this on an individual ruleset level.

Using !important to set animation/transition durations seems like a big ol' hammer, when that's not required (since we own the styles).

ellenoise’s picture

I'm not sure I follow, @mherchel could you expand on that or provide an example?

andrewmacpherson’s picture

Doing it at the level of the individual ruleset is fragile, and I'm strongly against it.

It means that every component which uses animation will need to have extra rules to turn it off. This in turn requires designers and developers to remember to implement prefers-reduced-motion for every component which uses animation. I'm willing to bet that eventually we'll have an animation that can't be turned off (contrib modules could likely be the cause of this).

The advantage of a global implementation of prefers-reduced-motion is that it provides a safety-oriented baseline to help users. It doesn't prevent individual components from handling animation differently if they need to, but it reduces the risk of animations which can't be turned off.

The argument is similar to the best practice for handling link underlines robustly; prioritize accessibility in the global default, rather than having to re-implement it for each component.

ellenoise’s picture

I think using !important is appropriate here. We want to set strong, global rules that won't be easily overridden.

katannshaw’s picture

@ellenoise: Thanks for your PR. I'm testing it on my MacBook with the Accessibility > Display > 'Reduce motion' set to on but I'm not seeing a difference. I've tried refreshing the page. Is there something else that I need to do to test this out?

andrewmacpherson’s picture

Further to #21, I tried the mobile menu today with an iPod touch 6th gen and iOS 12. I didn't see a difference with the reduce motion preference either.

andrewmacpherson’s picture

Re. #17:

Using !important to set animation/transition durations seems like a big ol' hammer, when that's not required (since we own the styles).

I feel this is missing an important point. We might own the style sheet, but crucially the user owns the platform preference which this media query reflects. It's !important to them, and we are respecting their wish. The whole category of user preference media features is about putting the user in control, not serving the convenience of developers and designers. It's a big ol' hammer which the user has asked for.

ellenoise’s picture

@katannshaw and @andrewmacpherson - Thank you for testing! katannshaw, yes, there is another step to test. Make sure to recompile the theme as you're testing locally. Have you run $ npm start or $ gulp watch inside the project?

I will double-check here, because I know this project is progressing quickly: What version of the POC are you testing against? My code is still in an open Pull Request on Github: https://github.com/Lullabot/olivero-poc/pull/26 This has not been merged to the Proof of Concept site yet, so the version that is up on Netlify will not have it. My PR branch is sorely behind master, so I will work on updating it! :)

ellenoise’s picture

StatusFileSize
new11.47 MB
andrewmacpherson’s picture

What version of the POC are you testing against?

I tested with whatever was currently at
https://olivero-poc.netlify.com/ at the time.

mherchel’s picture

Project: Olivero » Drupal core
Version: » 9.1.x-dev
Component: Code » Olivero theme
Status: Needs review » Needs work
kostyashupenko’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB
heatherwoz’s picture

Tested the patch in #28 against 9.2.x and it worked. Applied cleanly.

However I wonder if it should include rules for -webkit, -moz, etc. as in the earlier examples.

hinal05’s picture

StatusFileSize
new2.1 MB
new2.04 MB

I have applied patch #28 but I am not able to see any change after applying patch. Please check the GIF.

hinal05’s picture

Status: Needs review » Needs work
heatherwoz’s picture

@hinal05 Did you recompile the CSS and turn off motion in the OS settings? It took me a while to realize that disabling motion is not a browser setting but an OS setting.

kostyashupenko’s picture

Status: Needs work » Needs review

Please let's re-test it and in case of bugs - provide more information how did you test and where

andy-blum’s picture

StatusFileSize
new1.05 KB
new3.25 MB
new807.54 KB

I've re-rolled #28 and uploaded here.

Testing Instructions

  • Apply patch, clear cache
  • Set OS prefers-reduced-motion setting. If you need help finding this, MDN has some good guidance.
  • Scroll up and down, open mobile menu to confirm animations are happening at a speed too quick to be perceived as motion

olivero scrolling with reduced animation

olivero sidebar menu opening with reduced animation

imalabya’s picture

Patch #34 works perfectly. Moving to RTBC

vikashsoni’s picture

StatusFileSize
new1.08 MB
new1.08 MB

@andy-blum I have applied the patch but i can't see any changes for reference sharing screenshot

andy-blum’s picture

@vikashsoni did you change your OS settings to reduce motion? Are you using a browser that supports reduced motion (IE11 does not!). You can test your reduced motion settings with this codepen

@andrewmacpherson/@mherchel Playing with that codepen, however, I think we want to kill animations entirely, and not reduce the time to 1ms - that causes an extreme flashing phenomenon.

mherchel’s picture

Status: Needs review » Needs work

My thought is that we need to be more granular with this, as opposed to applying a hammer.

According to the spec, prefers-reduced-motion

Indicates that user has notified the system that they prefer an interface that minimizes the amount of movement or animation, preferably to the point where all non-essential movement is removed.

From my point of view, the "header slide out" animation is essential, as it indicates that the button is grabbing control of the visibility of the header. If a person is new to this theme, and they click the button, they might not even notice what happened.

There are several transitions that could be removed though including

  • the "down" function of the submenus at desktop widths
  • The "side in" function of the mobile menu

I don't think we should use this to remove color transitions, as (AFAIK) its motion that causes the vestibular difficulties, not color changes.

andy-blum’s picture

Status: Needs work » Needs review
StatusFileSize
new23.18 KB
new24.19 KB

Took a crack at a more granular approach to removing motion transitions. Patch & interdiff attached.

bnjmnm’s picture

@vikashsoni the before and after gifs you provided in #36 are the same file with different names, not before/after. The fact that your computer clock changes from 11:38 to 11:39 in both makes that quite clear.

mherchel’s picture

Status: Needs review » Needs work

The internet ate my earlier review. Here's another! Thanks for working on this.

No need to push `prefers-reduced-motion` into a variable. This value won’t be changing.

We should allow motion by default. By disabling animations, and then enabling them for browser that support the media query, we exclude IE11.

  1. +++ b/core/themes/olivero/css/components/header-navigation.css
    @@ -104,7 +104,13 @@
    +  transition: visibility 0.2s;
    

    The header animation serves a purpose where it informs the user what happened to the header. I believe this is an "essential" animation and should not be removed.

    If we do end up removing it, we should also remove the visibility transition.

  2. +++ b/core/themes/olivero/css/components/header-sticky-toggle.pcss.css
    @@ -76,8 +79,11 @@ body.is-always-mobile-nav .sticky-header-toggle {
    +        transition: opacity 0.2s;
    

    I don't want to exclude color changing (including opacity changes) from animating.

andy-blum’s picture

Version: 9.1.x-dev » 9.3.x-dev
Status: Needs work » Needs review
StatusFileSize
new16.97 KB
new23.67 KB
mherchel’s picture

gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new6.3 MB

Patch #42, fixes the user disable animation issue.
I checked Reduce motion setting, and tested.
Scroll up and down, open menu to confirm animations are happening at a speed too quick to be perceived as motion.

Marking as RTBC +1

Attached after patch screen recording for reference.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 42: 3093461_42.patch, failed testing. View results

gauravvvv’s picture

Status: Needs work » Reviewed & tested by the community
mherchel’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review

Still need to look at this.

Theresa.Grannum made their first commit to this issue’s fork.

chetanbharambe’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.42 MB

Verified and tested above merge request - https://git.drupalcode.org/project/drupal/-/merge_requests/1224.patch
Patch applied successfully and looks good to me.

Testing Steps:
# Goto: Appearance > apply Olivero theme
# Goto: System preference -> Click on Accessibility -> Click on Display and click on reduce motion checkbox. (For Macbook)
# Goto any page on Olivero theme
# Click on the Hamburger menu and close it when the user is doing scrolls at the top and bottom sides.

Expected Results:
# User should not see the animation effect on the Olivero theme.

Actual Results:
# Currently user is able to see animation effect on the Olivero theme.

Please refer attached video for the same
Looks good to me.
Can be a move to RTBC.

kostyashupenko’s picture

Rebased

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

This is looking great. We need to also disable the transition for the wide search form at https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/themes/olive...

andy-blum’s picture

Status: Needs work » Needs review

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Status: Needs review » Needs work

Back to needs work to address typos: https://www.drupal.org/pift-ci-job/2205059

--- Commands Executed ---
core/scripts/dev/commit-code-check.sh --drupalci
Return Code: 1
--- Output ---
Creating list of files to check by comparing branch to 9.3.x
/var/www/html/core/themes/olivero/css/components/header-search-wide.css:257:52 - Unknown word (transitionend)
/var/www/html/core/themes/olivero/css/components/header-search-wide.css:307:47 - Unknown word (transitionend)
/var/www/html/core/themes/olivero/css/components/header-search-wide.pcss.css:134:53 - Unknown word (transitionend)
/var/www/html/core/themes/olivero/css/components/header-search-wide.pcss.css:178:47 - Unknown word (transitionend)

CSpell: failed
ressa’s picture

Status: Needs work » Needs review

Since HTMLElement: transitionend event looks valid, perhaps it's more correct to add transitionend and related events transitioncancel, transitionrun, and transitionstart to /core/misc/cspell/dictionary.txt?

kristen pol’s picture

Ah, my mistake. I do see that transitionend has been added to core/misc/cspell/dictionary.txt in the MR. Does it need to be committed first?

Note that transitioncancel, transitionrun, and transitionstart aren't in any comments so they aren't triggering the error.

ressa’s picture

Status: Needs review » Needs work

I was close to correcting it to "transitioned" :) In the test it says "CSpell: passed", so adding transitionend seems to have taken care of the CSpell error.

But maybe the patch needs a re-roll against 9.4.x? I see a few offset's such as Hunk #1 succeeded at 194 (offset 1 line). when applying the latest patch.

ressa’s picture

Issue summary: View changes

Adding "How to disable animation" info in Issue Summary.

yogeshmpawar made their first commit to this issue’s fork.

yogeshmpawar’s picture

As mentioned in #58 I have rebased the current branch with 9.4.x so @ressa - can you please update target branch of merge request so irrelevant changes will not appear in https://git.drupalcode.org/project/drupal/-/merge_requests/1224#c1076630...

ressa’s picture

Thanks @yogeshmpawar, but I am not sure how to do that, sorry. I had a look at this page, but couldn't find an answer ... https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

Perhaps we need to click the "Create new branch" (target: https://git.drupalcode.org/issue/drupal-3093461/-/branches/new?branch_na...) on this page, to create a fresh 9.4.x branch?

yogeshmpawar’s picture

Hi @ressa - As this merge request created by you, you can able to edit this merge request & can able to change the target branch from 9.3.x to 9.4.x

ressa’s picture

StatusFileSize
new47.98 KB
new63.84 KB

I see what you mean, by looking at an MR created by me, which has an "Edit" button:

MR by me

But this MR was created by Theresa.Grannum, which you can also see if you check out MR #1224, there is no "Edit" button:

MR not by

yogeshmpawar’s picture

Status: Needs work » Needs review

Hey @ressa, so sorry for the confusion. I got confused between the names.
Thanks @theresagrannum for changing the branch to 9.4.x

andy-blum’s picture

Status: Needs review » Needs work

Code quality checks are failing. Please make sure to run core's linting commands

ressa’s picture

No problem @yogeshmpawar, and thank you for updating the MR @Theresa.Grannum.

andy-blum’s picture

Status: Needs work » Needs review

Passing tests!

gauravvvv’s picture

kristen pol’s picture

Status: Needs review » Needs work

Thanks for the updates. Back to needs work for some formatting cleanup.

andy-blum’s picture

Status: Needs work » Needs review

@Kristen Pol - all the feedback you left is on *.css files, which are compiled assets. Running yarn lint:css doesn't yield any errors, and yarn build:css doesn't make any changes, so I don't think these are things that need to be fixed. Moving back to needs review.

kristen pol’s picture

I've been trying to "resolve" all those unnecessary css file comments but the GitLab page is jumping around all over the place (maybe due to so many files in the MR). Anyway, sorry for the noise. It's weird that the compiling causes the semicolon removal and weird formatting.

The pcss changes looked okay to me.

mherchel’s picture

Status: Needs review » Needs work

Left a review in the MR requesting changes. Thanks for the work on this!

yogeshmpawar’s picture

Status: Needs work » Needs review

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andy-blum’s picture

Status: Needs review » Needs work

Needs rebase to 9.5.x or 10.1.x

mgifford’s picture

Issue tags: +wcag233

Adding SC 2.3.3 tag.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Postponed

The Olivero theme was approved for removal in #3590816: [policy, no patch] Deprecate Olivero and move to contrib.

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3595082: [meta] Tasks to deprecate the Olivero theme and the removal work in #3595085: [meta] Tasks to remove the Olivero theme.