Skip to content

Instantly share code, notes, and snippets.

@olibooty
Last active October 6, 2023 16:07
Show Gist options
  • Select an option

  • Save olibooty/13fbb4468bd61202f4209c1f1245097d to your computer and use it in GitHub Desktop.

Select an option

Save olibooty/13fbb4468bd61202f4209c1f1245097d to your computer and use it in GitHub Desktop.
A simple way to handle reduced motion preferences with a few lines and one media query
:root {
--prefers-reduced-motion: 1;
@media (prefers-reduced-motion) {
--prefers-reduced-motion: 0;
}
}
@function animationMs($speed) {
@return calc(#{$speed} * var(--prefers-reduced-motion))ms;
}
.someClass {
animation: slide animationMs(1) ease-in-out infinite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment