Problem/Motivation

The frontend library in pagedesigner_effects.libraries.yml loads GSAP/TweenMax, ScrollMagic and animate.css, and resources/js/effects.js registers every configured effect unconditionally. Nothing in the module consults the prefers-reduced-motion media query.

Specifically, Drupal.behaviors.pagedesigner_effects.attach() instantiates a ScrollMagic.Controller and then, for each configured trigger, registers scenes that toggle the pd-hidden class on the target and add animate.css classes (animated <effect>).

This has two consequences:

  • Accessibility. Visitors who have asked their operating system or browser to reduce motion still get scroll-triggered reveals, parallax and entrance animations — exactly what the preference exists to prevent. It also works against WCAG 2.1 SC 2.3.3 Animation from Interactions.
  • Deterministic rendering. Scroll-triggered elements are held hidden via pd-hidden until their scene fires, so any client that renders a page without a natural scroll — automated screenshots, print and PDF pipelines, some crawlers — can capture the page with content still invisible. Honouring the preference gives those clients a reliable way to reach the final, settled state.

Steps to reproduce

  1. Configure any scroll-triggered effect on a component or row via the Pagedesigner UI.
  2. Enable reduced motion — macOS Accessibility → Display → Reduce motion, Firefox ui.prefersReducedMotion=1, or Chrome DevTools Rendering → Emulate CSS prefers-reduced-motion.
  3. Load a page that uses the effect.

Expected: elements render in their final state, with no reveal, parallax or entrance animation.
Actual: every effect runs exactly as it does without the preference set.

Proposed resolution

Detect the preference once in resources/js/effects.js and take a no-animation path when it is set:

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

When reduceMotion is true:

  • Do not instantiate the ScrollMagic.Controller, and register no scenes or GSAP tweens.
  • Remove pd-hidden from every target immediately, so elements are visible i than waiting for a scene that will never fire.
  • For parallax and other tweens, apply the end values directly instead of animating to them.
  • Skip adding the animate.css animated classes.

Behaviour is unchanged for everyone else. Optionally, listen for changes on the media que at runtime is respected without a page reload.

Remaining tasks

  • Patch resources/js/effects.js.
  • Verify manually with reduced motion both on and off, on a page combining reveal, paral>
  • Unrelated but noticed while writing this: vendor/aos.js and vendor/ repo but are declared in neither <code>pagedesigner_effects.libraries.yml nor
    effects.js. If they are dead code they should be removed, in a separate issue.<

User interface changes

None for editors. Visitors who have requested reduced motion see effects configured in th in their final state, without animation.

API changes

None.

Data model changes

None. Stored effect configuration is untouched; only its runtime application changes.

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

guillaumepacilly created an issue. See original summary.

guillaumepacilly’s picture

Status: Active » Reviewed & tested by the community

guillaumepacilly’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

guillaumepacilly’s picture

Status: Fixed » Closed (fixed)