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

Prevent animations with prefers-reduced-motion #7757

Merged
merged 3 commits into from
Jul 21, 2023
Merged

Conversation

matthewp
Copy link
Contributor

Changes

  • Adds prefers-reduced-motion that eliminates the animations.
  • This is a "hammer" and maybe goes further than it should. But I'd rather go to extreme measures and then pull back later.

Testing

N/A

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2023

🦋 Changeset detected

Latest commit: 07455eb

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jul 21, 2023

Choose a reason for hiding this comment

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

The problem with this is that the fallback animations will still occur because those pseudo-elements don't exist in Firefox, etc.

This is why my solution used JavaScript in #7755 instead of Jake Archibald's suggestion-- however this will still be necessary to skip animations with the unstable meta tag version of View Transitions because that is not reliant on JavaScript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. We have a data attribute for the fallback. Does this cover it then? cda8dbf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this one is ok. The fallback will do the setTimeout wait since there are no animations, but that's ok. And I think it's still ok to call startViewTransition even if you are not doing animations.

Choose a reason for hiding this comment

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

[data-astro-transition-fallback] isn't working for me. The animations are still firing on Firefox, but [data-astro-transition-scope] seems to work fine as a selector. Would it ever not be placed on an animation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think it actually needs to be:

[data-astro-transition-fallback=new] [data-astro-transition-scope] {
  animation: none !important;
}

The animations are on the actual elements in the fallback. So yeah, it can be simplified to just use [data-astro-transition-scope]. I'll update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants