<?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: Saumay Paul</title>
    <description>The latest articles on DEV Community by Saumay Paul (@saumaypaul20).</description>
    <link>https://dev.to/saumaypaul20</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%2F444207%2Fbd96fa08-0ada-4134-b22c-b756175c8d3e.jpeg</url>
      <title>DEV Community: Saumay Paul</title>
      <link>https://dev.to/saumaypaul20</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saumaypaul20"/>
    <language>en</language>
    <item>
      <title>Rotate/Pusle Animation in React Native</title>
      <dc:creator>Saumay Paul</dc:creator>
      <pubDate>Wed, 22 May 2024 19:34:06 +0000</pubDate>
      <link>https://dev.to/saumaypaul20/rotatepusle-animation-in-react-native-19n4</link>
      <guid>https://dev.to/saumaypaul20/rotatepusle-animation-in-react-native-19n4</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8m48mo8w9dvehwlpkyk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8m48mo8w9dvehwlpkyk.png" alt="Rotate/Pusle Animation in React Native"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I implemented a continuous rotation and pulsing animation for an image using React Native's &lt;code&gt;Animated&lt;/code&gt; API. This small gist demonstrates how to create smooth, looping animations that can enhance the visual appeal of mobile applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Overview
&lt;/h3&gt;

&lt;p&gt;In this project, an image is animated to rotate continuously and pulse (scale up and down) simultaneously. Here’s a breakdown of how I achieved this:&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Explanation
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Setting Up the Animated Values:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rotateValue&lt;/code&gt;: Controls the rotation of the image.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pulseValue&lt;/code&gt;: Controls the pulsing effect (scaling) of the image.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Starting the Animations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rotation Animation:&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;Wrapped in &lt;code&gt;Animated.loop&lt;/code&gt; to ensure it repeats indefinitely.&lt;/li&gt;
&lt;li&gt;Uses Animated.sequence to create a smooth rotation effect.&lt;/li&gt;
&lt;li&gt;Animated.timing changes rotateValue from 0 to 1 over 4000 milliseconds and from 1 to 2 over another 4000 milliseconds, creating a full rotation every 8000 milliseconds.&lt;/li&gt;
&lt;li&gt;The Easing.linear function ensures a consistent rotation speed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pulse Animation:&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;Also wrapped in &lt;code&gt;Animated.loop&lt;/code&gt; to repeat indefinitely.&lt;/li&gt;
&lt;li&gt;Uses &lt;code&gt;Animated.sequence&lt;/code&gt; with two &lt;code&gt;Animated.timing&lt;/code&gt; calls to scale the image up to 1.5x its size and back down to its original size over 2000 milliseconds (1000 ms for scaling up and 1000 ms for scaling down).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Combining Transformations:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Applied to an &lt;code&gt;Animated.View&lt;/code&gt; containing the image.&lt;/li&gt;
&lt;li&gt;Transformations include &lt;code&gt;translateX&lt;/code&gt;, &lt;code&gt;translateY&lt;/code&gt; (for spiral effect), &lt;code&gt;rotate&lt;/code&gt;, and &lt;code&gt;scale&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Code Snippet
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You can view the full code on GitHub Gist: &lt;a href="https://gist.github.com/saumaypaul20/ce77c19b02b83ef2e3c4421f4f506738" rel="noopener noreferrer"&gt;LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can view the demo on Expo Snack: &lt;a href="https://snack.expo.dev/@saumay.paul/intrigued-blue-crackers" rel="noopener noreferrer"&gt;LINK&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This project showcases how powerful and flexible the &lt;code&gt;Animated&lt;/code&gt; API in React Native can be for creating engaging user interfaces. Animations like these can significantly improve user experience by adding a layer of interactivity and visual feedback.&lt;/p&gt;

&lt;p&gt;Feel free to check out the code, and I'd love to hear your thoughts and feedback! 🌟&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>animation</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
