<?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: meandrewandyou</title>
    <description>The latest articles on DEV Community by meandrewandyou (@meandrewandyou).</description>
    <link>https://dev.to/meandrewandyou</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%2F1079272%2F88c4080f-15da-4960-8b79-17d168561314.jpeg</url>
      <title>DEV Community: meandrewandyou</title>
      <link>https://dev.to/meandrewandyou</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meandrewandyou"/>
    <language>en</language>
    <item>
      <title>Touch event triggers :hover.</title>
      <dc:creator>meandrewandyou</dc:creator>
      <pubDate>Thu, 11 May 2023 07:26:55 +0000</pubDate>
      <link>https://dev.to/meandrewandyou/touch-event-triggers-hover-1744</link>
      <guid>https://dev.to/meandrewandyou/touch-event-triggers-hover-1744</guid>
      <description>&lt;p&gt;Hello, guys! I'm working on the project where I need some on &lt;code&gt;:hover&lt;/code&gt; CSS changes to animate the component. I only need this behavior on devices with the pointer, I don't need touch events to trigger them. And I thought that's what &lt;code&gt;:hover&lt;/code&gt; exists for. But unfortunately touch events can imitate hover. I was looking for an answer and found this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;media&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;your&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;hover&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="nx"&gt;red&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;p&gt;This &lt;code&gt;@media&lt;/code&gt; tag actually tracking if the device has a pointer or not. If not, hover event won't be executed. My question is: is it the right and overall the best way to achieve what's expected?&lt;br&gt;
Here's minimal &lt;a href="https://svelte.dev/repl/34f24fc6f2f842bc9fc4e283e7eabb35?version=3.59.1"&gt;demonstration repo&lt;/a&gt;.&lt;br&gt;
If you're in Chrome - RMB click -&amp;gt; Inspect -&amp;gt; Toggle device toolbar (in a top left corner of dev tools) -&amp;gt; select Nest Hub Max. Now cursor becomes a "finger" and you could push on the div and it will animate. If you're in another browser - do something similar with it's dev tools. Just be sure to select the touchscreen device with the screen big enough to display all the content of the repo.&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>css</category>
    </item>
  </channel>
</rss>
