Respect the browser "prefers-reduced-motion" setting

Created on 18 February 2025, about 2 months ago

Problem/Motivation

The GDPR cookie compliance banner currently has an animation effect by default. It would be nice if this animation were conditional based on whether the browser has passed a "prefers-reduced-motion" media query.

See the MDN documentation on prefers-reduced-motion to see how to enable this feature in most browsers.

One challenge is that this feature is only available in CSS. EU Cookie Compliance module would probably be better off using CSS animations anyway instead of the jQuery $.animate() function, but if it is easier to continue using JavaScript to do the animation, the prefers-reduced-motion value can be retrieved via a JavaScript trick as well.

Although I think this option would be good to comply with user preferences and possibly to improve accessibility, the primary reason I would like this feature is so that visual regression testing software (such as Tugboat) already pass the "prefers-reduced-motion" setting when running testing, and this would make it so that EU Cookie Compliance module would not be constantly causing false positives in test failures.

Steps to reproduce

  • Enable reduced motion in your operating system or browser. See MDN documentation on prefers-reduced-motion.
  • Visit site with EU Cookie Compliance enabled and a "Banner sliding animation time" set, such as 700ms.
  • Ideally, the banner would not animate when "prefers-reduced-motion" is "reduce". And it would continue to animate when "prefers-reduced-motion" is "no-preference".

Proposed resolution

Option 1: Switch to using CSS animation and use the @media (prefers-reduced-motion) { media query.
Option 2: Detect the media query with JavaScript and set the animation time to 0 if prefers-reduced-motion is "reduce".

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States quicksketch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024