Question details:
display:none transition:all animate through a method of jsMy render function (not react-native) :
render() {
return (
<View className="container">
<Touchable onPress={this.pressHandle}>Click</Touchable>
<View ref="box">
{this.state.show ? <Text className="show">show Text</Text> : null}
</View>
</View>
);
}
when I click the component Touchable, it whill change this.state.show,and conditional render the component <Text>
How can I use my animate function ,such as anmate(){...} to achieve transition?
I did it like this:(it didn't work)
pressHandle(){
this.setState({
show:!this.state.show
});
this.transitionHandle();
}
transitionHandle(){
animate(this.refs.box,{
opacity:1
// ....
})
}
You need to keep it rendered in the DOM so that you can apply CSS to it conditionally.
Change this:
{this.state.show ? <Text className="show">show Text</Text> : null}
To:
<Text className="show">show Text</Text>
And either change the CSS styles of your ref or add/remove a class name and control the transition completely in CSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With