Skip to content

d2svg: honor prefers-reduced-motion for animated connections - #2976

Merged
alixander merged 2 commits into
d2lang:masterfrom
wasabihu:fix/1979-reduced-motion
Nov 24, 2026
Merged

alixander merged 2 commits into
d2lang:masterfrom
wasabihu:fix/1979-reduced-motion

Conversation

@wasabihu

Copy link
Copy Markdown
Contributor

Fixes #1979

Summary

  • Add a @media (prefers-reduced-motion: reduce) rule for .animated-connection in d2renderers/d2svg/d2svg.go (animation: none !important;) to stop connection animations when reduced motion is enabled, overriding inline animation and animation-direction styles without altering default animations or non-animated SVG output.
  • Add regression tests in d2renderers/d2svg/animated_connection_reduced_motion_test.go covering standard unidirectional, standard bidirectional, sketch animated, and static connections.
  • Update affected animated-connection SVG snapshots (d2renderers/d2sketch/testdata, d2renderers/d2svg/dark_theme/testdata, and e2etests/testdata) and ci/release/changelogs/next.md.

Testing

  • go test -count=1 ./d2renderers/... ./d2cli/... ./e2etests/... (all passed)

AI-assisted contribution.

@alixander alixander left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we scope .animated-connection to the diagram’s hash class before merging? When the SVG is embedded inline, the current rule also stops animations on unrelated page elements that use the same class. I verified that scoping it fixes that and still honors Reduce Motion.

  • sent from alixander's Codex

@wasabihu

Copy link
Copy Markdown
Contributor Author

Good catch — I scoped the reduced-motion rule to .d2-<hash> .animated-connection using the diagram's hash class (matching the other scoped selectors in d2svg) and updated the tests and SVG snapshots accordingly. Ready for another look!

@alixander alixander left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagram hash fixes the inline SVG scoping issue. I verified in Chrome that Reduce Motion stops the diagram’s connections while a host-page element using the same class keeps animating. The connections animate normally with the default setting. Thanks for the fix!

  • sent from alixander's Codex

@alixander
alixander enabled auto-merge November 24, 2026 14:59
@alixander
alixander merged commit 963407a into d2lang:master Nov 24, 2026
14 checks passed
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

Successfully merging this pull request may close these issues.

Animated connections don't honor prefers-reduced-motion

2 participants