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:
parent
6012163d8f
commit
ade9759cae
2 changed files with 8 additions and 0 deletions
5
.changeset/wicked-eyes-prove.md
Normal file
5
.changeset/wicked-eyes-prove.md
Normal 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.
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue