I am trying to make a animation screen something like this picture but I am not done properly. b I want like this picture which I uploaded. I am not good in animation please help me to improve my code. I am stuck in animation.
this is what I tried.
import React, { Component } from 'react'
import { View, Image, Animated, Easing } from 'react-native'
const backgroundImage = require("../../../assets/icons/post.jpeg")
export default class Splash extends Component {
constructor(props) {
super(props)
this.state = { spinAnim: new Animated.Value(0) }
}
componentDidMount() {
this.handleAnimation()
}
handleAnimation = () => {
console.log("rree")
Animated.timing(
this.state.spinAnim,
{
toValue: 1,
duration: 500,
easing: Easing.linear,
useNativeDriver: true
}
).start();
}
render() {
const spin = this.state.spinAnim.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg']
});
return (
<View>
<View style={{ flex: 1 }}>
<Animated.Image
source={backgroundImage}
resizeMode='cover'
style={{
position: 'absolute',
left: 40,
top: 100,
height: 100,
width: 100,
transform: [
{ rotate: spin },
]
}}
/>
</View>
</View>
)
}
}
I think you should use react-native-animatable library. In this library you have lot's of animations and transitions which you want to use. it is very easy to usable
import * as Animatable from 'react-native-animatable';
<Animatable.Text animation="zoomInUp">Zoom me up, Scotty</Animatable.Text>
and in this library you have more props to use like onAnimationEnd
when animation is ended you can call a function if you want.