{"id":6432,"date":"2019-09-27T19:18:27","date_gmt":"2019-09-27T19:18:27","guid":{"rendered":"https:\/\/cheesecakelabs.com\/blog\/?p=6432\/"},"modified":"2022-07-01T17:14:33","modified_gmt":"2022-07-01T17:14:33","slug":"first-steps-with-react-native-animations","status":"publish","type":"post","link":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/","title":{"rendered":"First steps with React Native animations"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Recently I was given the opportunity to work in a React Native project, as a developer, most of my experience was with React, so I was thrilled with expanding my knowledge in this area.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As I started studying the platform, I got really interested in how to make animations using React Native, and in this blogpost, I am going to share my experience, and create a guide for beginners on how to start animating your <a href=\"https:\/\/cheesecakelabs.com\/blog\/blog\/react-native-examples-innovative-brands\/\">React Native apps<\/a>. In this guide, we are going to create a Burger Button that when activated spins and turns into an X button. For this, introductory knowledge of React Native will be required.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To follow the code, use the instructions in Getting Started with <a href=\"https:\/\/facebook.github.io\/react-native\/docs\/getting-started\">React Native<\/a><\/span><span style=\"font-weight: 400;\">, and then we can start our guide.<\/span><\/p>\n<p><!--more--><\/p>\n<h2><span style=\"font-weight: 400;\">The<\/span><span style=\"font-weight: 400;\"> Library<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The library we are going to use is the Animated API, from React Native\u2019s standard library. It has two drivers for animating, the first one uses the JavaScript engine created by React Native, and the second one creates animations using the native driver. The library is still being worked on and intends on expanding the number of native animations that it provides.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are different techniques provided by this library to animate your component\u2019s properties, the most basic being `Animated.timing`. To show this we are going to begin creating a simple burger button.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> React <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">'react'<\/span>\n<span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> { StyleSheet, View, TouchableWithoutFeedback } <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">'react-native'<\/span>\n\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={() =&gt; {}}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;View style={styles.burgerButton}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">)<\/span>\n\n<span style=\"font-weight: 400;\">const styles = StyleSheet.create({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; container: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; flex: 1,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; backgroundColor: '#fff',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; alignItems: 'center',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; justifyContent: 'center'<\/span>\n<span style=\"font-weight: 400;\">&nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; burgerButton: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; display: 'flex',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; flexDirection: 'column',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; justifyContent: 'space-between',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; alignItems: 'center',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; width: 100,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; height: 100,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; paddingVertical: 20,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; borderRadius: 50,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; backgroundColor: 'green'<\/span>\n<span style=\"font-weight: 400;\">&nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; inner: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; width: '60%',<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; height: 10,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; borderRadius: 10,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; backgroundColor: 'black'<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n<span style=\"font-weight: 400;\">})<\/span>\n\n<span style=\"font-weight: 400;\">export default App<\/span><\/code><\/pre>\n<p>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6441\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-27-at-15.56.12.png\" alt=\"Inactive button\" width=\"586\" height=\"316\"><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Any resemblance with a music playing app is purely coincidental. But before we can begin animating this component, we have to add a wrapper to the views we want to animate, so we can dynamically change its properties. This wrapper is provided by Animated, and it needs to be used for all of the components you wish to animate.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> React <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">'react'<\/span>\n<span style=\"font-weight: 400;\">import<\/span><span style=\"font-weight: 400;\"> {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; [...],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; Animated<\/span>\n<span style=\"font-weight: 400;\">} <\/span><span style=\"font-weight: 400;\">from<\/span> <span style=\"font-weight: 400;\">'react-native'<\/span>\n\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={() =&gt; {}}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;View style={styles.burgerButton}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">)<\/span>\n\n<span style=\"font-weight: 400;\">[...]<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Now that we have setup the basis, we are going to use the `Animated.timing` function to begin animating the relevant properties. This function takes a property with a value created by Animated\u2019s method Animated.Value, and updates it according to instructions. First we are going to translate the upper and lower parts of the button to the middle. Why we need to do this for our animation will be explained later.<\/span><\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">[...]<\/span>\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [activated, setActivated] = useState(<\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [upperAnimation, setUpperAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [lowerAnimation, setLowerAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> startAnimation = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; setActivated(!activated)<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.timing(upperAnimation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; toValue: activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">25<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.timing(lowerAnimation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; toValue: activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">-25<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> animatedStyles = {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; lower: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: lowerAnimation<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; upper: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: upperAnimation<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={startAnimation}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;View style={styles.burgerButton}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.upper]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.lower]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; )<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">[...]<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6447\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/First-Animation.gif\" alt=\"\" width=\"588\" height=\"276\"><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">With this, we have our first animation in React Native. As you can see, we created a function that uses Animated Timing to change the value of our translateY property, and passed this value to our Animated Views through an object called animatedStyles.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Interpolation<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Now we are going to see how to animate more complicated properties, such as color, and rotation. To achieve such animations, we are going to have to use the mathematical concept of Interpolation, which consists of constructing new data points within the range of a discrete set of known data points (according to Wikipedia).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Fortunately, we don\u2019t need any mathematical knowledge for this, we can use Animated to interpolate our data, which means, it can calculate which colors would make sense in the animation between two given colors. For example, this is how it would look like if we wanted our button to change colors from green to red when activated. Additionally, we are going to use interpolation to clean up our code, and remove the repeated values in the translate animations.<\/span><\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">[...]<\/span>\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [activated, setActivated] = useState(<\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [animation, setAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> startAnimation = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> toValue = activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">1<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; setActivated(!activated)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.timing(animation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> animatedStyles = {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; lower: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">-25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; upper: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; burgerButton: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; backgroundColor: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'green'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'red'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={startAnimation}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style={[styles.burgerButton, animatedStyles.burgerButton]}<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.upper]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={styles.inner} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.lower]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/Animated.View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; )<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">[...]<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6449\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/Second-Animation.gif\" alt=\"\" width=\"580\" height=\"252\"><\/p>\n<p><span style=\"font-weight: 400;\"><br \/>\nTo interpolate our data, we have to use our animated property\u2019s method `interpolate`, and pass into it an input range and an output range. The input range must be the value of the range of our animated property, and output range the initial and final value of the component\u2019s property we wish to animate.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Interpolate supports mapping strings, this way, you can pass rotation values, and colors (either by names or RGB hex codes). To continue the animation of our button, now we are going to make the middle part of the button disappear as the animation occurs.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">[...]<\/span>\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [activated, setActivated] = useState(<\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [animation, setAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> startAnimation = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> toValue = activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">1<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; setActivated(!activated)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.timing(animation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> animatedStyles = {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; lower: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">-25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; upper: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; middle: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; height: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">10<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; burgerButton: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; backgroundColor: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'green'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'red'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={startAnimation}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style={[styles.burgerButton, animatedStyles.burgerButton]}<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.upper]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.middle]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.lower]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/Animated.View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; )<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">[...]<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6450\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/Third-Animation.gif\" alt=\"\" width=\"588\" height=\"296\"><\/p>\n<p><span style=\"font-weight: 400;\">Additionally, we can pass an array with more than only two numbers to both input and output range parameters, with this we could make an animation that has different interactions in the output depending on the range of the input, like an animation that is really fast in the beginning, and slower in the end, similar to keyframe animations in CSS.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Composing Animations<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">For now we have only used Animated\u2019s timing method, but there are other possibilities to animate your values. For the rotation we are going to use Animated.Spring, which is an animation function that does not take a duration, it only needs a toValue to work, but you can set friction and tension or speed and bounciness to improve your animation. The spring animation imitates a physical spring, and so, it overshoots the toValue that you provide, the amount it overshoots depends on the values we set before.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To make this animation run in parallel with our previous animation we need to use Animated\u2019s parallel function, which takes an array of Animated methods and runs them in parallel. In our example we are going to use high tension and low friction on our spring, so it will be really bouncy:<\/span><\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">[...]<\/span>\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [activated, setActivated] = useState(<\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [animation, setAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [rotation, setRotation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> startAnimation = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> toValue = activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">1<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; setActivated(!activated)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.parallel([<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; Animated.timing(animation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; }),<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; Animated.spring(rotation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; friction: <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; tension: <\/span><span style=\"font-weight: 400;\">140<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; ]).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> animatedStyles = {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; lower: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">-25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate: rotation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'0deg'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'45deg'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; upper: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate: rotation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'0deg'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'-45deg'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; middle: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; height: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">10<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; burgerButton: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; backgroundColor: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'green'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'red'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={startAnimation}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style={[styles.burgerButton, animatedStyles.burgerButton]}<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.upper]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.middle]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.lower]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/Animated.View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; )<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">[...]<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6448\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/Full-Animation.gif\" alt=\"\" width=\"588\" height=\"308\"><\/p>\n<p>&nbsp;<\/p>\n<p>With this, we have finished our animation. <span style=\"font-weight: 400;\">Other possibilities for composing animations are sequence, that waits until one animation ends for the other to begin, and delay, that waits a given amount a time after an animation begins to start the next one.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Comparison with CSS animations<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">If you have any experience with CSS animations, you can see the similarities. With CSS animations we can declare a transition which will watch for a given CSS property change and automagically interpolate the values for this property to pass during the transition, or we can declare a keyframe animation and decide what we want to happen in the progression of our animation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With React Native we have to use an approach similar to the CSS keyframe animations, and declare how we want our animation to progress. The main advantage of CSS animation vs React Native Animation is that not all of the properties of CSS are in React Native styles, one example we have on our burger button is the transform origin CSS property.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If we wanted to create the rotation animation of our button, we could declare the transform origin of our upper part of the burger, for example, as left and simply rotate it to 45 degrees, and reach the same animation as the one we did in this course, which needed a translateY to the final position where rotating 45 degrees from the center of the bar would reach the position we want.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">But this is not a problem with Animated, it\u2019s a problem with React Native in general, but more and more CSS properties are being added to React Native, and I believe, eventually it will reach a realm of possibilities very similar to that of CSS3 in general.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Native Animations<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In the introduction of the blogpost I talked about the possibility of creating native animations, but until now we haven\u2019t used any of it. Not everything we can do with Animated is supported by the native driver, as a rule of thumb, we cannot animate layout properties, we can animate things like transform and opacity.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In our project, we can use native driver for anything, except the background color and the height of the middle part of the button. But Animated only supports one driver per animation, so we cannot declare a Native Driver for this animations that do not support it, we have to declare a separate, non native driver for them. The way we use the native driver is very simple, we simply have to set a boolean in the animation to true, as follows:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre class=\"language-javascript\"><code class=\"language-javascript\"><span style=\"font-weight: 400;\">[...]<\/span>\n<span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> App = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [activated, setActivated] = useState(<\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [animation, setAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [jsAnimation, setJsAnimation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> [rotation, setRotation] = useState(<\/span><span style=\"font-weight: 400;\">new<\/span><span style=\"font-weight: 400;\"> Animated.Value(<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">))<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> startAnimation = <\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> =&gt; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> toValue = activated ? <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\"> : <\/span><span style=\"font-weight: 400;\">1<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; setActivated(!activated)<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; Animated.parallel([<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; Animated.timing(animation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; useNativeDriver: <\/span><span style=\"font-weight: 400;\">true<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; }),<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; Animated.spring(rotation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; friction: <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; tension: <\/span><span style=\"font-weight: 400;\">140<\/span><span style=\"font-weight: 400;\">,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; useNativeDriver: <\/span><span style=\"font-weight: 400;\">true<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; }),<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; Animated.timing(jsAnimation, {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; toValue,<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; duration: <\/span><span style=\"font-weight: 400;\">300<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; ]).start()<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> animatedStyles = {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; lower: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">-25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate: rotation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'0deg'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'45deg'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; upper: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; transform: [<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translateY: animation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">25<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate: rotation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'0deg'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'-45deg'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; ]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; middle: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; height: jsAnimation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">10<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; },<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; burgerButton: {<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; backgroundColor: jsAnimation.interpolate({<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; inputRange: [<\/span><span style=\"font-weight: 400;\">0<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">],<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; outputRange: [<\/span><span style=\"font-weight: 400;\">'green'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'red'<\/span><span style=\"font-weight: 400;\">]<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; })<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; }<\/span>\n<span style=\"font-weight: 400;\">&nbsp; }<\/span>\n\n<span style=\"font-weight: 400;\">&nbsp; <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> (<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;View style={styles.container}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;TouchableWithoutFeedback onPress={startAnimation}&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style={[styles.burgerButton, animatedStyles.burgerButton]}<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.upper]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.middle]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Animated.View style={[styles.inner, animatedStyles.lower]} \/&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/Animated.View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &nbsp; &lt;\/TouchableWithoutFeedback&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; &nbsp; &lt;\/View&gt;<\/span>\n<span style=\"font-weight: 400;\">&nbsp; )<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">[...]<\/span>\n<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">This won\u2019t change our animation, it will simply make it more fluid and consume less memory.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">With these few basic concepts, we can get started creating useful animations that will improve our users experience with our apps.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Furthermore, with React Native and Animated, we can also track gestures using the Animated.event method and create dynamic animations, like dragging an element or scrolling. Also, we can use libraries to improve our animations, some that I tend to use are libraries that create SVG animations, like <a href=\"https:\/\/github.com\/veltman\/flubber\">flubber.js<\/a>&nbsp;<\/span><span style=\"font-weight: 400;\">and<\/span> <span style=\"font-weight: 400;\"><a href=\"https:\/\/github.com\/d3\/d3-interpolate\">D3-Interpolate<\/a><\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There is still much to be improved in React Native\u2019s Animated API, but the path ahead for the platform is very exciting and filled with very smart people. This was my take on how to start with animating your React Native apps, any suggestions are more than welcome.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Thank you for reading!<\/span><\/p>\n<p><a href=\"https:\/\/cheesecakelabs.com\/blog\/blog\/top-5-react-native-development-company\/\">Cheesecake Labs ranked Top #5 React Native Development Company Worldwide by Clutch<\/a><\/p>\n<p><a href=\"https:\/\/cheesecakelabs.com\/blog\/contact\/\"><img decoding=\"async\" class=\"size-full wp-image-7260 aligncenter\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2021\/03\/Blog-banner-CTA.png\" alt=\"\" width=\"650\" height=\"200\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><b>References<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/tobiasahlin.com\/blog\/meaningful-motion-w-action-driven-animation\/\"><span style=\"font-weight: 400;\">https:\/\/tobiasahlin.com\/blog\/meaningful-motion-w-action-driven-animation\/<\/span><\/a><\/p>\n<p><a href=\"https:\/\/facebook.github.io\/react-native\/docs\/animations\"><span style=\"font-weight: 400;\">https:\/\/facebook.github.io\/react-native\/docs\/animations<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was given the opportunity to work in a React Native project, as a developer, most of my experience was with React, so I was thrilled with expanding my knowledge in this area. As I started studying the platform, I got really interested in how to make animations using React Native, and in this [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":6433,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[432],"tags":[400],"class_list":["post-6432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering","tag-tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>First steps with React Native animations<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"First steps with React Native animations\" \/>\n<meta property=\"og:description\" content=\"Recently I was given the opportunity to work in a React Native project, as a developer, most of my experience was with React, so I was thrilled with expanding my knowledge in this area. As I started studying the platform, I got really interested in how to make animations using React Native, and in this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-27T19:18:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T17:14:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\"},\"author\":{\"name\":\"Mateus Bueno\"},\"headline\":\"First steps with React Native animations\",\"datePublished\":\"2019-09-27T19:18:27+00:00\",\"dateModified\":\"2022-07-01T17:14:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\"},\"wordCount\":1463,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png\",\"keywords\":[\"JavaScript\"],\"articleSection\":[\"Engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\",\"name\":\"First steps with React Native animations\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png\",\"datePublished\":\"2019-09-27T19:18:27+00:00\",\"dateModified\":\"2022-07-01T17:14:33+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Mateus Bueno\"},\"breadcrumb\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png\",\"width\":2000,\"height\":720,\"caption\":\"cellphone inside react native molecule logo\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cheesecakelabs.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"First steps with React Native animations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"name\":\"Mateus Bueno\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/\",\"url\":false,\"contentUrl\":false,\"caption\":\"Mateus Bueno\"},\"description\":\"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/autor\/mat-bueno-ferreira\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"First steps with React Native animations","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/","og_locale":"en_US","og_type":"article","og_title":"First steps with React Native animations","og_description":"Recently I was given the opportunity to work in a React Native project, as a developer, most of my experience was with React, so I was thrilled with expanding my knowledge in this area. As I started studying the platform, I got really interested in how to make animations using React Native, and in this [&hellip;]","og_url":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2019-09-27T19:18:27+00:00","article_modified_time":"2022-07-01T17:14:33+00:00","og_image":[{"width":2000,"height":720,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png","type":"image\/png"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Written by":null,"Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#article","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/"},"author":{"name":"Mateus Bueno"},"headline":"First steps with React Native animations","datePublished":"2019-09-27T19:18:27+00:00","dateModified":"2022-07-01T17:14:33+00:00","mainEntityOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/"},"wordCount":1463,"commentCount":0,"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png","keywords":["JavaScript"],"articleSection":["Engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/","url":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/","name":"First steps with React Native animations","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage"},"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png","datePublished":"2019-09-27T19:18:27+00:00","dateModified":"2022-07-01T17:14:33+00:00","author":{"@type":"person","name":"Mateus Bueno"},"breadcrumb":{"@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#primaryimage","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2019\/09\/React_Native_Animation.png","width":2000,"height":720,"caption":"cellphone inside react native molecule logo"},{"@type":"BreadcrumbList","@id":"https:\/\/cheesecakelabs.com\/blog\/first-steps-with-react-native-animations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cheesecakelabs.com\/blog\/"},{"@type":"ListItem","position":2,"name":"First steps with React Native animations"}]},{"@type":"WebSite","@id":"https:\/\/cheesecakelabs.com\/blog\/#website","url":"https:\/\/cheesecakelabs.com\/blog\/","name":"Cheesecake Labs","description":"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","name":"Mateus Bueno","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/","url":false,"contentUrl":false,"caption":"Mateus Bueno"},"description":"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.","url":"https:\/\/cheesecakelabs.com\/blog\/autor\/mat-bueno-ferreira\/"}]}},"_links":{"self":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/6432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=6432"}],"version-history":[{"count":1,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/6432\/revisions"}],"predecessor-version":[{"id":10191,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/6432\/revisions\/10191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media\/6433"}],"wp:attachment":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=6432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=6432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=6432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}