<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paul Oloyede on Medium]]></title>
        <description><![CDATA[Stories by Paul Oloyede on Medium]]></description>
        <link>https://medium.com/@ayopaulofficial?source=rss-4c3bd94d7f98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*plW9lsaJylW1r4-7IiUl7w.jpeg</url>
            <title>Stories by Paul Oloyede on Medium</title>
            <link>https://medium.com/@ayopaulofficial?source=rss-4c3bd94d7f98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 19:48:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayopaulofficial/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Animations: A Beginner Guide To Scale Transform In React-Native]]></title>
            <link>https://medium.com/@ayopaulofficial/animations-a-beginner-guide-to-scale-transform-in-react-native-c99c28c15350?source=rss-4c3bd94d7f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/c99c28c15350</guid>
            <category><![CDATA[mobile-apps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Paul Oloyede]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 02:55:15 GMT</pubDate>
            <atom:updated>2022-09-28T02:55:15.621Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m3iKTwyM6HH3w5JS" /><figcaption>Photo by <a href="https://unsplash.com/@sonance?utm_source=medium&amp;utm_medium=referral">Viktor Forgacs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>From E-commerce to Finance applications, and even down to Cryptocurrency mobile applications, animations are used to communicate the effect of actions to the users.</p><p>Animation contributes largely to the sophisticatedness seen in recent mobile applications. This brings us to one of the animations property that is widely used in mobile applications, The <strong>Scale</strong> <strong>Transform</strong> property.</p><blockquote><em>Scale transform is resizing the dimensions of an item. it involves increasing and decreasing the range of values on a component&#39;s X and Y axis. The X and Y dimensions can be scaled separately or together depending on the requirement of motion effect. The scaling effect is appealing if appropriately implemented. Scale is a way to control the size of an element, by increasing and decreasing the element.</em></blockquote><blockquote><em>Additionally, Scale transform can be used to create flip animations in react-native.</em></blockquote><p>This article is a friendly guide to helping beginners understand the benefit and usage of Scale property in react native. At the end of the guide, you will be able to implement a scale transform animation and be confident to explore more fun ways to animate elements using this property on your own.</p><p>To follow through with this guide, you will have to set up your environment before getting started. Make sure to meet the requirements below for you to code along.</p><h4>Prerequisites</h4><p>Tools and technology stack required to follow through this article:</p><ul><li><a href="https://www.freecodecamp.org/news/full-javascript-course-for-beginners/">knowledge of JavaScript</a></li><li><a href="https://www.freecodecamp.org/news/react-beginner-handbook/">knowledge of React</a></li><li><a href="https://www.freecodecamp.org/news/command-line-for-beginners/">knowledge of running command line/terminal instructions</a></li><li><a href="https://www.freecodecamp.org/news/how-to-install-node-js-and-npm-on-windows/">Node.js and npm installed on your machine</a></li><li><a href="https://docs.expo.dev/get-started/installation/">Install Expo CLI and Expo Go</a></li><li>XCode or Android Studio is installed on your machine.</li><li>Some experience with React Native.</li></ul><p>If you are new to the ecosystem you may want to start from the <a href="https://reactnative.dev/docs/environment-setup">React Native Guide</a>.</p><p>Having set up your environment, you can proceed to the getting started section.</p><h3>Getting Started</h3><p>Open a command prompt window, and navigate to where you will like to save your application from the command prompt. Enter the following command to create a new application:</p><pre>npx create-expo-app rn-scale</pre><p>Once the application has been created, navigate to the rn-scale folder, you will see a couple of files created at the root of the project.</p><p>At the root of the application, there is an App.js the file that contains a starter code.</p><p>To start the application run the following command on the terminal:</p><p>For iOS devices:</p><pre>yarn ios</pre><p>For Android devices:</p><pre>yarn android</pre><p>Running these commands would instruct the react-native compiler to bundle the code and display the user interface.</p><p>This is what you should see on the screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MtjeRdN4qYatlFruP8x3gA.png" /><figcaption>react-native start screen</figcaption></figure><p>Now that you’re being able to run the application locally, let look at a concept that could help understand what scaling an element is all about.</p><h3>Animating Width and Height Directly</h3><p>Above, in the introduction section, it was stated that scale transformation is resizing of an element or component. Resizing the width and height of an element is often the effect of scale transform. One of the ways to resize width and height in react native is by controlling the width and height style properties directly.</p><p>Take a look at the example demo below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m99QDmWc3H90Gk2AHoO6dg.gif" /><figcaption>animated element by width and height</figcaption></figure><p>From the demo, on click of the yellow box, the yellow area enlarges to two (2) times its’ initial size, this is done by manipulating the width and height.</p><p>Here is the code that does that for the demo above:</p><pre>import React, { useRef } from &quot;react&quot;;<br>import {<br>  StyleSheet,<br>  View,<br>  TouchableWithoutFeedback,<br>  Animated,<br>} from &quot;react-native&quot;;</pre><pre>export default function AnimatedWidthHeight() {<br>  const scaleAnimate = useRef(new Animated.Value(100)).current;</pre><pre>  const animateElement = () =&gt; {<br>    Animated.timing(scaleAnimate, {<br>      toValue: 200,<br>      duration: 2000,<br>      useNativeDriver: false,<br>    }).start();<br>  };</pre><pre>  const animationStyle = {<br>    width: scaleAnimate,<br>    height: scaleAnimate,<br>  };</pre><pre>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;TouchableWithoutFeedback onPress={() =&gt; animateElement()}&gt;<br>        &lt;Animated.Image<br>          source={require(&quot;../assets/home.jpg&quot;)}<br>          style={[ animationStyle ]}<br>        &gt;&lt;/Animated.Image&gt;<br>      &lt;/TouchableWithoutFeedback&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>    backgroundColor: &quot;#4b0082&quot;,<br>  },<br>});</pre><p>At top of the code, the React package and useRef hook are imported. Below the first line, from the react-native package, imports are brought in to build the user interface and implement logic.</p><p>Explanation of the react native libraries used:</p><ul><li>StyleSheet: for internal styling of the user interface.</li><li>View: for building the user interface. The View element is used as a container for the entire user interface in the code above.</li><li>TouchableWithoutFeedback: is a button element that can be pressed to trigger the animation. Also, the onPress props on the TouchableWithoutFeedback is used to call the animateElement() function.</li><li>Animated: this is the library used to animate elements in this tutorial.</li></ul><blockquote><em>Note: other animation libraries can be used to animate elements in react native.</em></blockquote><p>The scaleAnimate holds the value of the Animated.Value. The Animated.Value is a mutable singular value that can be changed without re-rendering the component.</p><p>The Animated.Value is wrapped in the useRef call so that it only gets created once when the component renders for the first time. Animated.Value is giving a default value of 100.</p><p>In the animateElement(), Animated.timing will animate scaleAnimate from 100 to 200, passingtoValue , duration, and useNativeDriver as configuration values.</p><p>Using the Animated.timing method, the width, and height are animated from 100 to 200 respectively. The start() is the trigger to initiate the animation in the Animated class component.</p><p>Also, the animatedStyle variable holds the width and height style properties that are dynamically changed when the component is animated.</p><p>In the user interface, the Animated.Image element is transformed in the demo above. The Animated.Image is the Image component being wrapped around by the Animated class component from react native library, making the Image component animateable.</p><p>Animating width and height properties affect layout in react native, while this can be very useful in some certain cases, it comes with its own but.</p><p>This method of scaling pixels in react native is not performant when a huge number of items are involved. From the react native <a href="https://reactnative.dev/docs/performance#animating-the-size-of-an-image-drops-ui-thread-fps">documentation</a>, you find a good recommendation as to how this can be achieved.</p><h3>Scaling Elements Efficiently</h3><p>According to the react native <a href="https://reactnative.dev/docs/performance#animating-the-size-of-an-image-drops-ui-thread-fps">documentation</a>, it is recommended to scale elements using the transform: [{scale}] style property.</p><p>Here is a demo of scaling elements using the scale transform property:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WfPdP74Zw-a6r1YRFry8A.gif" /><figcaption>animated element by scale transform</figcaption></figure><p>From the presentation above, clicking on the image area transforms the image, zooming in and out within a range of values.</p><p>This is similar to the previous example we saw while animating width and height, the difference here is that the scale property is used to resize elements which is more performant and efficient when dealing with a large amount of data.</p><p>Here is the code below that gets that done:</p><pre>import React, { useRef, useState } from &quot;react&quot;;<br>import {<br>  StyleSheet,<br>  View,<br>  TouchableWithoutFeedback,<br>  Animated,<br>} from &quot;react-native&quot;;</pre><pre>export default function Scale() {<br>  const scaleAnimate = useRef(new Animated.Value(0)).current;<br>  const [isToggle, setIsToggle] = useState(false);</pre><pre>  const scaleInterpolate = scaleAnimate.interpolate({<br>    inputRange: [0, 1],<br>    outputRange: [3, 2],<br>  });</pre><pre>  const animateElement = () =&gt; {<br>    const toValue = isToggle ? 0 : 1;</pre><pre>    Animated.timing(scaleAnimate, {<br>      toValue: toValue,<br>      duration: 2000,<br>      useNativeDriver: true,<br>    }).start(() =&gt; {<br>      setIsToggle(!isToggle);<br>    });<br>  };</pre><pre>  const animationStyle = {<br>    transform: [<br>      {<br>        scale: scaleInterpolate,<br>      },<br>    ],<br>  };</pre><pre>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;TouchableWithoutFeedback onPress={() =&gt; animateElement()}&gt;<br>        &lt;Animated.Image<br>          source={require(&quot;../assets/home.jpg&quot;)}<br>          style={[{ height: 100, width: 100 }, animationStyle]}<br>        &gt;&lt;/Animated.Image&gt;<br>      &lt;/TouchableWithoutFeedback&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>    backgroundColor: &quot;#4b0082&quot;,<br>  },<br>});</pre><p>A few differences exist between the Animated Width and Height section source code and the one above.</p><p>Explanation of the scale transform method:</p><ul><li>There is an array destructuring on the useState hook, assigning the value from the hook to the isToggle variable and setIsToggle function. This is useful for tracking the changes and updating the state of the application.</li><li>The scaleInterpolate variable holds the resulting value from the .interpolate function. Using interpolation, the inputRange value changes from 0 to 1, it&#39;s interpolate the value from 3 to 2 in the outputRange.</li><li>Inside the animateElement(), a toValue variable is defined to store the outcome of the conditional check, setting it&#39;s value to 0 when isToggle is true or 1 when it&#39;sfalse. These values map to the inputRange values.</li><li>You will observe that the isToggle value is updated in the start() method call, by using the setIsToggle function destructured from the useState hook.</li><li>In the animationStyle object variable, the transform property can take an array of objects separated with a comma. In order, to change the dimensions of the image area, the transform property takes an array with an object, where the scale property is set to the returned value from scaleInterpolate.</li></ul><blockquote><em>Note: The transform property can also take values such as </em><em>scaleX and </em><em>scaleY. The </em><em>scaleX property is used to transform elements along the horizontal axis, while the </em><em>scaleY property transforms elements on the vertical axis. The </em><em>scale property transforms elements on both the X and Y axis.</em></blockquote><h3>Summing Up</h3><p>In this article, you’ve learned how to scale elements in react native. The following was covered in this how-to article:</p><ul><li>The definition, and importance of scaling items in mobile applications.</li><li>Create and setup a react native project locally</li><li>Explored the width and height scaling animations without using the scale transform property.</li><li>Examined the performance effect of animating dimensions with the width and height properties.</li><li>Also, showed how to animate dimensions with the scale transform property.</li></ul><p>Would appreciate your comments and suggestions about the tutorial in the comment box.</p><p>Also, you can reach me on Twitter <a href="https://twitter.com/ayopaulofficial">@ayopaulofficial</a> and on LinkedIn at <a href="https://www.linkedin.com/in/paulayo/">Paul Oloyede</a></p><p>Thanks for Reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c99c28c15350" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can we Animate Opacity in React Native?]]></title>
            <link>https://medium.com/@ayopaulofficial/can-we-animate-opacity-in-react-native-2581298f403?source=rss-4c3bd94d7f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/2581298f403</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Paul Oloyede]]></dc:creator>
            <pubDate>Fri, 02 Sep 2022 10:52:54 GMT</pubDate>
            <atom:updated>2022-09-02T10:52:54.185Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qriUmhCo-viJCgrE" /><figcaption>Photo by <a href="https://unsplash.com/@bigkids?utm_source=medium&amp;utm_medium=referral">David Werbrouck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Opacity means transparency of an object or element used to control the visibility of an element. It helps with a gradual entrance and gradual exit to prevent any sort of jarring layout movements that may affect the user negatively. When change occurs for an opacity value, it affects the visibility of the component in which such change is been acted upon.</p><p>You can set opacity values from 0 to 1 which is equivalent to 0% to 100%. So for example, we can set our opacity value to 0.1, or 0.5 based on how much visibility or transparency we want or the message being conveyed to a user at the time.</p><h4>The benefit of Animating Opacity</h4><ul><li>One of the core importance of animating this value when changed is to give the smooth transitioning effect to the eye of the user, basically not changing visuals in an unappealing manner. This can at times irritate the user.</li><li>Allow the user to see the effect of their action, and not living them to wonder if there was any at all.</li><li>Creating a connection between each state of your application.</li><li>it helps to convey or drive the message home with ease.</li><li>it can be used as a guide for the user when they need to perform some actions that are required. Take, for example, a button that can remain disabled until some form fields are filled and validated. it is often implemented by blurring out the button component until these actions or requirements are met.</li></ul><h4>Prerequisites</h4><ul><li>Basic knowledge of JavaScript</li><li>Basic knowledge of React</li><li>Basic knowledge of running CLI commands</li><li>Node.js and npm installed on your machine</li><li>XCode or Android Studio installed on your machine</li><li>Some experience with React Native (suggested, not required)</li></ul><h3>Getting Started</h3><p>Let’s create a new expo project using this command:</p><pre>npx create-expo-app rn-opacity</pre><p>In the root of the application that we’ve just created, there is an App.js file that contains a starter code to show us the application is up and running properly after installation.</p><p>So let&#39;s run our app using this command yarn ios for iOS and yarn android for android devices respectively, we will see the content of the component appear on our screen.</p><pre>import { StatusBar } from &#39;expo-status-bar&#39;;<br>import { StyleSheet, Text, View } from &#39;react-native&#39;;</pre><pre>export default function App() {<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Text&gt;Open up App.js to start working on your app!&lt;/Text&gt;<br>      &lt;StatusBar style=&quot;auto&quot; /&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &#39;#fff&#39;,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>});</pre><h3>Building the UI</h3><p>Can we add a component structure to demonstrate our example? Yes, that’s possible!</p><p>In our source code is an orange box, where we use View component to build the UI and style the backgroundColor to orange</p><p>we import the react library on line 1.</p><p>On line 2 we import StyleSheet for writing external styles, View for building our UI, and TouchableWithoutFeedback button component for achieving interaction or state switch trigger.</p><pre>import React from &quot;react&quot;;<br>import { StatusBar } from &quot;expo-status-bar&quot;;<br>import { StyleSheet, View, TouchableWithoutFeedback } from &quot;react-native&quot;;</pre><pre>export default function App() {<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;TouchableWithoutFeedback onPress={() =&gt; null}&gt;<br>        &lt;View<br>          style={styles.box}<br>        &gt;&lt;/View&gt;<br>      &lt;/TouchableWithoutFeedback&gt;</pre><pre>      &lt;StatusBar style=&quot;auto&quot; /&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>  box: {<br>            backgroundColor: &quot;orange&quot;,<br>            height: 200,<br>            width: 200,<br>            opacity: 0.5,<br>          }<br>});</pre><h3>Putting Everything Together</h3><p>In our App.js file below, we have added quite many changes, let&#39;s go through the lines of code for an explanation.</p><pre>import React, { useRef } from &quot;react&quot;;<br>import { StatusBar } from &quot;expo-status-bar&quot;;<br>import {<br>  StyleSheet,<br>  View,<br>  TouchableWithoutFeedback,<br>  Animated,<br>} from &quot;react-native&quot;;</pre><pre>export default function App() {</pre><pre>  const opacityAnimation = useRef(new Animated.Value(0.5)).current;<br></pre><pre>  const opacityStyle = { opacity: opacityAnimation };</pre><pre>  const animateElement = () =&gt; {</pre><pre>    Animated.timing(opacityAnimation, {<br>      toValue: 0,<br>      duration: 1500,<br>      useNativeDriver: true<br>    }).start(() =&gt; {<br>      Animated.timing(opacityAnimation, {<br>        toValue: 1,<br>        duration: 1500,<br>        useNativeDriver: true<br>      }).start()<br>    })<br>  };</pre><pre>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;TouchableWithoutFeedback onPress={() =&gt; animateElement()}&gt;<br>        &lt;Animated.View style={[styles.box, opacityStyle]}&gt;&lt;/Animated.View&gt;<br>      &lt;/TouchableWithoutFeedback&gt;</pre><pre>      &lt;StatusBar style=&quot;auto&quot; /&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>  box: {<br>    backgroundColor: &quot;orange&quot;,<br>    height: 200,<br>    width: 200,<br>    opacity: 0.5,<br>  },<br>});</pre><p>We declare an opacityAnimation variable to hold the Animated.value which is set to 0.5. This means that the opacity value of our box at default when rendering it&#39;s 0.5</p><p>While on line 13, in our code, we also declare a variable to hold an object for the opacity style we would be changing dynamically and we set the opacity property to the value of opacityAnimation.</p><p>In the animateElement function we access the Animated.timing method. Timing will specify the animation of a single value to another value over a set period, so its function signature is opacityAnimation and then the configuration object. In our config object we have the following options:</p><ul><li>toValue: the new value we are animating to.</li><li>duration: lenght of animation in milliseconds</li><li>useNativeDriver: allows native code to perform the animation on the UI thread.</li></ul><p>To trigger a change, we need to call start method as we have it in our source code.</p><p>Also where we are rendering our UI we have replaced the View component with Animated.View component. The Animated library wraps around the normal View element</p><p>The call the animateElement function in our TouchableWithoutFeedback button component. Where it is passed into the onPress function props.</p><p>Clicking within the box area would trigger our animations, allowing it to fade out from 0.5 to 0 and then fade in from 0 to 1 for 1500 milliseconds on both calls.</p><p>Here is a demo of the app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzf27Z7jSH48vl8JjTYL0w.gif" /><figcaption>Example of a functional app</figcaption></figure><h4>Summary</h4><p>A good use case where this can be applied is in a Button component, a Checkbox component, and a Radio Button component. You will find this implementation useful for achieving visual effects appealing to the user when interacting with your apps.</p><p>Thanks for stopping by, hope you find this tutorial useful.</p><p>Cheers!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2581298f403" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>