<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Duane Chetcuti</title>
    <description>The latest articles on DEV Community by Duane Chetcuti (@duanecreates).</description>
    <link>https://dev.to/duanecreates</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F292722%2F4c45c4c9-df3c-4e69-a87a-08707127bf10.png</url>
      <title>DEV Community: Duane Chetcuti</title>
      <link>https://dev.to/duanecreates</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/duanecreates"/>
    <language>en</language>
    <item>
      <title>Media Query: prefers-reduced-motion</title>
      <dc:creator>Duane Chetcuti</dc:creator>
      <pubDate>Thu, 07 May 2020 15:35:16 +0000</pubDate>
      <link>https://dev.to/duanecreates/media-query-prefers-reduced-motion-1225</link>
      <guid>https://dev.to/duanecreates/media-query-prefers-reduced-motion-1225</guid>
      <description>&lt;h2&gt;
  
  
  Why we use animations
&lt;/h2&gt;

&lt;p&gt;Animations are not just awesome to see, but they can help deliver a message, or help the user in some way. They are only useful when done right, when there's a reason why you need to use them. They are very easy to get wrong, to be too much, too slow, too fast. Motion can guide the user or get their attention. &lt;/p&gt;

&lt;p&gt;A common scenario where animations are used is when loading something. Users hate waiting, so a simple animation can help distract them. With the right animation, the user might even enjoy waiting. 😄&lt;/p&gt;

&lt;h2&gt;
  
  
  Love it or hate it
&lt;/h2&gt;

&lt;p&gt;I love animations, but others could have a very different opinion, and that's fine. For some it's a matter of taste, but for others it's about health. Some people get sick because of animations. It has become common to have the option to tone down or turn off animations on your device. This is a real problem, even if it is not very common. &lt;/p&gt;

&lt;p&gt;So should we stop using animations altogether? &lt;strong&gt;No!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Media Queries
&lt;/h2&gt;

&lt;p&gt;CSS has been advancing a lot lately, making our styling not only better to look at, but also smarter. We can cater for more people, easily.&lt;/p&gt;

&lt;p&gt;One of the media queries in CSS is &lt;em&gt;prefers-reduced-motion&lt;/em&gt;, which uses the mentioned setting of the operating system. This makes it super easy for us developers to know if the user wants to dial down the animations. Keep in mind that this media query only returns two values: &lt;strong&gt;no-preference&lt;/strong&gt; or &lt;strong&gt;reduce&lt;/strong&gt;. You cannot know if the user wants to completely remove the animations or just reduce them from this media query, so it's not perfect, but it gives us enough information to work with.&lt;/p&gt;

&lt;h3&gt;
  
  
  How To Use
&lt;/h3&gt;

&lt;p&gt;It's used just like any other media query. You use it to overwrite the previous styling. I would put it in the bottom and target the transitions of every element. However this highly depends on your situation, as some styling is more complex. In this case I am only using CSS transitions to keep it simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="m"&gt;0.5s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* this transitions all supported properties on change */&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate3d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;15deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefers-reduced-motion&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c"&gt;/* disable all transitions */&lt;/span&gt;
    &lt;span class="nl"&gt;transition-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;
    CLICK ME!
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Browser Support
&lt;/h3&gt;

&lt;p&gt;Browser support is pretty good! All the major browsers support it, apart from IE, nothing new there.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9foV1WIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://caniuse.bitsofco.de/image/prefers-reduced-motion.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9foV1WIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://caniuse.bitsofco.de/image/prefers-reduced-motion.webp" alt="prefers-reduced-motion browser support" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>css3</category>
      <category>animation</category>
      <category>a11y</category>
    </item>
  </channel>
</rss>
