Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
React Native Animated Loading Screen :)
I am going to talk about my Animated Loading Screen in React Native and how you can build your own Loading screen using React Native Animated API with EASE .
There are tutorials which describe the animated API . So , I am not going talk about that. I will only talk about how i made my own animation using the animated API .
First, there are four components you can animate using the Animated API.
In my case, I wanted to animate a View, a Image inside another View.
To animate something, you need to do the following,
1 . An Animated Value.
Import Animated from react native. Then, Create a new Animated Value Object. Assign the value to a this Object property in constructor. Which you will given as the first parameter of animated methods.
2. Give a style Property to the animated Component
Let’s Move to main Topic, I wanted to animate these two animated component.
Animated.View
Animated.Image
If you don’t understand it, don’t worry . I will give the full code example.
To animate a Component, You need to give a style property to the Component , just like CSS . I have given two style :truckStyle , scaleText
Now its time to define these styles. I used transform style for my cases and scaled it according to the animated value.
3 . Animated Methods and Don’t forget to start and stop them.
There are various methods that ships with the animated API.
They take two parameters. first: an Animated value , second: a configuration Objects
The most used are:
These two are kind independent. They are used with other animation methods like :
I only used the upper two in my cases. But you can combine them with the later two to create more dynamic beautiful animation.
I wanted to start the animated on screen render . so, in ComponentDidMount , I called them with the parameters . The configuration object must have toValue property. the other values are optional ….
At last , I have started the animation with start() method.
The, End Game, is like the video below. ( yes ! i am a Marvel fan too )
Thanks for reading …. the full code is below ….
For Details , check out the doc …
React Native Animated Splash Screen :) was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.