<?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 jasmo2 on Medium]]></title>
        <description><![CDATA[Stories by jasmo2 on Medium]]></description>
        <link>https://medium.com/@ComJasmo2?source=rss-baf4bedd925f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TFd_6B0cCwCTLonLa5eOjA.jpeg</url>
            <title>Stories by jasmo2 on Medium</title>
            <link>https://medium.com/@ComJasmo2?source=rss-baf4bedd925f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:28:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ComJasmo2/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[React-navigation custom animation for React Native ]]></title>
            <link>https://medium.com/@ComJasmo2/react-navigation-custom-animation-for-react-native-6ffeae6c66c9?source=rss-baf4bedd925f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ffeae6c66c9</guid>
            <category><![CDATA[transitions]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[custom]]></category>
            <dc:creator><![CDATA[jasmo2]]></dc:creator>
            <pubDate>Mon, 22 Jul 2019 14:01:01 GMT</pubDate>
            <atom:updated>2019-07-22T14:01:01.258Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the 2º part series in React Native Animations. (<a href="https://link.medium.com/x04wuQblbY">Here you can find the 1ºone</a>). The following post will cover custom animations transitions on react-navigation.</p><p>Usually, applications are more than just one screen. Moreover, these screens are part of a navigation flow that needs to be smooth on its transitions, that way give our final user a fluid sensation throw the app navigation.</p><p>In the next example will use <strong>StackNavigation</strong> as an example. Our main focus will be to understand the basic usage of animations transitions. Additionally, we will base on the next library <a href="https://github.com/plmok61/react-navigation-transitions">react-navigation-transitions</a> which already has some really cool animations between screens and has less than 250 code lines.</p><h3>Basics</h3><pre>const animationFunction = () =&gt; {<br>  return {<br>    transitionSpec: { ... },<br>    screenInterpolator: { ... }<br>  }<br>}</pre><pre>createStackNavigator({<br>  Screen1: {<br>    screen: Screen1,<br>  },<br>  Screen2: {<br>    screen: Screen2,<br>  },<br>},</pre><pre>{<br>  transitionConfig: () =&gt; animationFunction()<br>})</pre><p>In the code above show how a basic animation between screens is done. <strong>transitionConfig</strong> requires 2 options for an appropriate animation <strong><em>transitionSpec</em></strong> which is in charge of basic properties of the animation, such as <em>duration</em> and <em>easing</em> and <strong><em>screenInterpolator</em></strong> that will animate style properties such as <em>position</em> or <em>opacity</em>.</p><p>The header could also be animated, and the API provides us the next options:</p><ul><li><em>headerLeftInterpolator</em></li><li><em>headerTitleInterpolator</em></li><li><em>headerRightInterpolator</em></li></ul><h3>Example</h3><p>Now that we understand the definitions, let us take a look at a simple transition and break it down for a better understanding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b2bd916501babd0165a455680c12034/href">https://medium.com/media/0b2bd916501babd0165a455680c12034/href</a></iframe><p>To understand what is happening we will need to go throw the to options given by the API <em>transitionSpec</em> and <em>screenInterpolator</em>.</p><h4>transitionSpec:</h4><p>As mention before takes properties required for animations such as <em>duration, Easing curve, timing handling function, </em>and we could choose whether or not to use the <em>native driver </em>in the animation as well<em>.</em></p><h4>screenInterpolator:</h4><blockquote>The scene renderer props are nearly identical to the props used for rendering a transition. The exception is that the passed scene is <em>not the active scene</em> but is instead the scene that the renderer should render content for.</blockquote><p>It is clear that this function is focused on the scene that will render, and not the active one. <br>By the way, this function will receive an object which contains the props listed below, which is very useful at the moment we manipulate the animation:</p><pre><em>//</em> The layout of the screen container<br><strong>layout</strong><em>: </em><strong><em>NavigationLayout<br></em></strong>// The destination navigation state of the transition<br><strong>navigation<em>: NavigationScreenProp&lt;NavigationState&gt;</em></strong><br>// The progressive index of the transitioner&#39;s navigation state.<br><strong>position<em>: AnimatedValue</em></strong></pre><pre>// The value that represents the progress of the transition when navigation state changes from one to another. Its numeric value will range from 0 to 1. <br>//  progress.__getAnimatedValue() &lt; 1 : transition is happening.<br>//  progress.__getAnimatedValue() == 1 : transition completes.<br><strong>progress<em>:</em> <em>AnimatedValue</em></strong></pre><pre>// All the scenes of the transitioner.<br><strong>scenes<em>: Array&lt;NavigationScene&gt;</em></strong></pre><pre>// The active scene, corresponding to the route at `navigation.state.routes[navigation.state.index]`. When rendering NavigationSceneRendererPropsIndex, the scene does not refer to the active scene, but instead the scene that is being rendered. The index always is the index of the scene<br><strong>scene<em>: NavigationScene</em></strong></pre><pre><strong>index<em>: number<br></em>screenProps?</strong><em>: {},</em></pre><h3><strong>Implementation:</strong></h3><h4><em>Simple:</em></h4><p>To use the function just need to add the following configuration:</p><pre>createStackNavigator({<br>  Screen1: {<br>    screen: Screen1,<br>  },<br>  Screen2: { <br>    screen: Screen2,<br>  },<br>}, {<br>  headerMode: &#39;none’,<br>  transitionConfig: fromRight()<br>});</pre><p>Just by adding it, we will add the same custom transition to all transition animation.</p><p>The result should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*RxXz9XdxFuxrHW33Xl-QgQ.gif" /><figcaption>Simple custom animation</figcaption></figure><h4><em>Advance:</em></h4><p>In this more advanced implementation we will take into account the following:</p><ul><li>Forward-reverse transitions</li><li>Independent screens animations</li><li>Outgoing screen animation</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/757d3d8e11e3c8655f2c9124f0ab7c16/href">https://medium.com/media/757d3d8e11e3c8655f2c9124f0ab7c16/href</a></iframe><p>The previous method is quite similar to the <em>simple version, but </em>the main difference are the incoming options; from which <strong><em>Outgoing screen animation</em></strong> is been calculated.</p><p>The key point is to calculate <em>finalWidth, </em>which is based on a percentage of the initial width the layout-API provide.</p><p>Once calculated it must be placed on the <em>outputRange </em>due to, it tells how much is the outgoing screen is gonna move respect to the actual one.</p><p>On the other hand, both <em>Independent Screen Animations</em> and <em>Forward-Reverse Transitions</em> are been manage with additional options in <strong><em>transitionConfig.</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/749f8d6f8b300124b0439c0d90d20f40/href">https://medium.com/media/749f8d6f8b300124b0439c0d90d20f40/href</a></iframe><p>Let us take a look at the following sections in the code <strong>handleCustomTransition, screenVerification, </strong>if(screenIndex &gt;= sceneCount — 1) , due to each of them controls a key part of the transition animations</p><h4><strong>handleCustomTransition:</strong></h4><p>To handle the animation properly we need <strong><em>prevScene, nextScene, sceneIndex, sceneCount </em></strong>all of this is possible due to, we have access to the <em>nav</em> object inside the method.</p><h4>(sceneIndex &gt;= sceneCount — 1), Validation:</h4><p>This logic is focused on verifying if the screen is moving forward or backward, giving us a powerful tool to control depending on the transition flow.</p><h4>(screenVerification(sceneConfig, ‘ScreenA’, ‘ScreenB’)), Validation:</h4><p>Contrary to the previous validation. This one verifies which are the screens involved in the transition animation that is going to be executed.</p><p>Tada here in the result of the Advance configuration. it takes all the concepts mention above an executes the animation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*darhWoRKumiTcOG8Y2jTnQ.gif" /><figcaption>Advance Transition animation</figcaption></figure><h3>Time to play</h3><blockquote>As the old adage “practice makes perfect”</blockquote><p>Is your time to put hands on the code and play with all the concepts you just read in this small tutorial. Below you are going to find a <strong>Snak.io</strong> link as a playground to test your own animation version.</p><p><a href="https://snack.expo.io/@jasmo2/simple-react-navigation-animation">https://snack.expo.io/@jasmo2/simple-react-navigation-animation</a></p><p>Twitter: <a href="https://medium.com/u/baf4bedd925f">jasmo2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ffeae6c66c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Truth about react-native animations]]></title>
            <link>https://medium.com/the-truth-about-react-native-animations/the-truth-about-react-native-animations-998d039080e4?source=rss-baf4bedd925f------2</link>
            <guid isPermaLink="false">https://medium.com/p/998d039080e4</guid>
            <dc:creator><![CDATA[jasmo2]]></dc:creator>
            <pubDate>Tue, 09 Jul 2019 12:09:39 GMT</pubDate>
            <atom:updated>2019-07-09T12:11:58.863Z</atom:updated>
            <content:encoded><![CDATA[<p>Usually getting into a new topic feels overwhelming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*X0wRGT5OQksCr9g_lKRD0w.gif" /></figure><p>This is how I first felt trying to get into RN animations. The amount of information out there is humongous and getting into the information you need at the right time could me a complicated task.</p><p>In the past few weeks I have been working on a RN project that needed animations enhances, at this point I begun to research what to use and how to use it depending on each task.</p><p>Due to this the post will divide in three part serie that will cover my journey.</p><h3>Basics</h3><p>As natural as it seems it was not my case, this is also a good recommendation for you to follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hH5JPFcoHIEVG1ZDPBctkQ.jpeg" /><figcaption>Just take a look at <a href="https://facebook.github.io/react-native/docs/animations">https://facebook.github.io/react-native/docs/animations</a></figcaption></figure><p>Lets start at the basics. So to begin there are 2 types of animations in react native:</p><ul><li>LayoutAnimation API</li><li>Animated API</li></ul><h4>LayoutAnimationAPI</h4><p><strong>LayoutAnimation</strong> is usually used after calling setState due to it results in changing the layout.</p><p>When can see it clearly in the following example where we want to change the <em>View </em>size after the button is pressed.</p><h4><a href="https://snack.expo.io/@jasmo2/layoutanimationapi-example">https://snack.expo.io/@jasmo2/layoutanimationapi-example</a></h4><p>Just to give you a little bit more context each time setState is been called the height and width, additionally LayoutAnimation.easeinEaseOut()will interpreted how to animate those layout changes.</p><h4>AnimatedAPI</h4><p>This API will bring us the flexibility to create animations not just based in a component state, also it will bring us the opportunity to control the animation via <strong>value, time </strong>and <strong>event. </strong>Most over ,the API gives 3 different methods to create animations which are:</p><ul><li><strong>Animated.spring() </strong>— Simple single-spring physics model</li><li><strong>Animated.timing()</strong> — Maps time range to easing value.</li><li><strong>Animated.decay() — </strong>starts with an initial velocity and gradually slows to a stop.</li></ul><p>We will be covering Animated.timing() due to the other 2 methods are specific cases of this one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7d28892ed50797172f9d4e1907be7cf/href">https://medium.com/media/b7d28892ed50797172f9d4e1907be7cf/href</a></iframe><p>For basic animation we must set both initial value and final value, it tells the animation which is its start and ending point. Therefore, this method also accepts duration , delay , easing which are going to be cover later in the post.</p><p>Before diving-in , in any example lets take a look to the methods that are use to execute the animations:</p><ul><li><strong>Animated.sequence()<br></strong>It receives an array of animations which are executed one after another, waiting first that the previous animation ends completely.</li></ul><blockquote>A valid clarification here is if the current animations is stopped the next one is not executed.</blockquote><ul><li><strong>Animated.parallel()<br></strong>It receives an array of animations, and start them all at the same time.</li><li><strong>Animated.stagger()<br></strong>This one is a mix between <em>parallel </em>and<em> sequence</em> animations. It receives and array of animations and a delay. It will start the animations one after another but with a delay between them.</li></ul><h3>Practical Example</h3><p>Lets go into the main business. A practical example that uses this concepts. The main idea here is to create three bouncing balls animation. It will have a stagger effect between each other, and each ball will have its own animation handler which is useful to understand how it works.</p><p>As 1º step we need to import the <strong>Animated</strong> Library as well as <strong>Easing. </strong>This last one to describe how the animation should behave.</p><pre>import { StyleSheet,Text,View,<strong>Easing</strong>,<strong>Animated </strong>} from &#39;react-native&#39;</pre><h4>Constructor</h4><p>Due to this component is think to be reusable across the application it requires some initial values. Circles amount, color and radius</p><pre>constructor(props) {<br>  super(props)<br>  const { backgroundColor, radius, heightDistance } = props<br>  this.state = {<br>    animatedValue: arrGen(props.circles, () =&gt; new <strong><em>Animated.Value(0)</em></strong>),<br>    circlesArr: arrGen(props.circles, 0),<br>    currentIndex: -1,<br> };</pre><pre>  this.styleDots = {<br>    backgroundColor: backgroundColor,<br>    borderRadius: radius,<br>    height: radius * 2,<br>    width: radius * 2,<br>  };<br>}</pre><p>our next step is to define our render method in which we will create dynamically the bouncing balls we want to render.</p><p>— — — —</p><pre>animatedViews = () =&gt; {<br>  const { backgroundColor, heightDistance, radius } = this.props<br>  const { animatedValue, circlesArr } = this.state<br>  <br>  const circlesComponents = circlesArr.map((_, i) =&gt; {<br>    const <strong>moveY</strong> = animatedValue[i]<em>.</em><strong><em>interpolate</em></strong><em>({<br>     </em><strong><em> inputRange: [0, 1],<br>      outputRange: [0, heightDistance],<br>    })</em></strong>;<br>    const animatedView = (<br>      &lt;Animated.View <br>        key={i}<br>        style={[this.styleDots, <em>{ </em><strong><em>transform</em></strong><em>: [{ translateY: moveY }] }]}</em><br>      /&gt;<br>    );<br>    return animatedView;<br>  });<br>  <br>  return circlesComponents<br>}</pre><pre>render() {<br>  const animatedViews = this.animatedViews();<br>  return &lt;View style={styles.container}&gt;{animatedViews}&lt;/View&gt;;<br>}</pre><p>The code above shows us the methods Animated.Value() that tell which is the initial value where the animation is gonna begin and .interpolate({...}) which maps the original value range to more simple one, in this case the final range is from <em>0–1. </em>Additionally, due to the <strong><em>transform</em></strong><em> </em>property is the one we are going to<em> </em>animate, for this reason it receives the <em>moveY.</em></p><pre>componentDidMount() {<br>  this.animate(this.animate);<br>}</pre><pre>animate = callback =&gt; {<br>  const { delay, speed, circles } = this.props</pre><pre>const { animatedValue } = this.state<br>  const sequenceArr = this.sequenceArr()<br>  <strong><em>Animated.stagger</em></strong>(<em>delay</em>, sequenceArr).start(val =&gt; {<br>    callback &amp;&amp; callback(this.animate)<br>  })<br>}</pre><pre>sequenceArr = () =&gt; {<br>  const { speed, circles } = this.props;<br>  const { animatedValue } = this.state;<br>  const arr = [];</pre><pre>  for (let index = 0; index &lt; circles; index++) {<br>    arr.push(<br>      <strong><em>Animated.sequence</em></strong>([<br>        <em>Animated.timing</em>(animatedValue[index], {<br>          easeOut,<br>          duration: speed / 2,<br>          toValue: 1,<br>        }),<br>        <em>Animated.timing</em>(animatedValue[index], {<br>          easeIn,<br>          duration: speed / 2,<br>          toValue: 0,<br>        }),<br>      ])<br>    );<br>  }</pre><pre>  return arr;<br>};</pre><p>The main reason the animation function is been called in <em>componentDidMount</em>, is because we need to begin the animation as soon as we can.</p><p>Both <em>stagger</em> and <em>sequence</em><strong><em> </em></strong>are combine to create the bouncing animation for simultaneous balls as shown in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kVXA7KbUYZ9qk4031jF7Xg.gif" /><figcaption>Bouncing balls animation</figcaption></figure><p>For better understanding and to play with the code refer to:</p><blockquote><a href="https://snack.expo.io/@jasmo2/bounce-three">https://snack.expo.io/@jasmo2/bounce-three</a></blockquote><p>Conclusions to getting started in animations, just start basic and understand what you are doing. All libraries are on top of it. So have how it works in top of mind will be very useful to even to used more advance libraries such as <a href="https://github.com/oblador/react-native-animatable"><strong>Animatable</strong></a><strong> </strong>, <a href="https://github.com/IjzerenHein/react-native-magic-move"><strong>MagicMove</strong></a><strong> </strong>or even the transitions inside <a href="https://reactnavigation.org/"><strong>react-navigation</strong></a>. All of this we will be covering in following series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998d039080e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-truth-about-react-native-animations/the-truth-about-react-native-animations-998d039080e4">The Truth about react-native animations</a> was originally published in <a href="https://medium.com/the-truth-about-react-native-animations">The Truth about react-native animations</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>