I have an Animatable.Text
element in my React Native app, and I want it to fade in an out, but spend more time faded in than faded out. In other words, I want its opacity to behave like a sine curve, but where it's steeper and flatter at the top than a regular sine curve. This is what I have so far:
const pulseOpacity = {
0: {
opacity: 0
},
0.5: {
opacity: 1
},
1: {
opacity: 0
}
}
<Animatable.Text
animation={pulseOpacity}
duration={2000}
iterationCount={'infinite'}
>{this.props.text}</Animatable.Text>
Does anyone know how I can approach making the text be visible for longer?
You can use the
easing
prop for that purpose. Set it toease-in
when the text is about to fade andease-out
when the text is about to appear. You can choose from different available functions likeease-in-sine
if you'd like.You can read more about easing here.