0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00

Warn when view transitions run on a prefer-reduced-motion device (#10222)

* Warn when view transitions run on a prefere-reduced-motion device

* ViewTransitions.astro aktualisieren

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
Martin Trapp 2024-02-26 17:04:57 +01:00 committed by GitHub
parent 6012163d8f
commit ade9759cae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Adds a warning in DEV mode when using view transitions on a device with prefer-reduced-motion enabled.

View file

@ -51,6 +51,9 @@ const { fallback = 'animate' } = Astro.props;
}
if (supportsViewTransitions || getFallback() !== 'none') {
if (import.meta.env.DEV && window.matchMedia('(prefers-reduced-motion)').matches) {
console.warn(`[transitions]: all view transition animations, including fallback animation, are disabled as this device has the prefer-reduced-motion setting enabled.`);
}
document.addEventListener('click', (ev) => {
let link = ev.target;
if (ev.composed) {