【发布时间】:2018-07-30 02:34:43
【问题描述】:
问题详情:
- 原生环境
- 我无法使用
display:none - 我无法使用
transition:all - 我只能通过js的方法使用
animate
我的渲染函数(不是 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>
);
}
当我点击组件Touchable时,它会改变this.state.show,并有条件地渲染组件<Text>
如何使用我的动画功能,如anmate(){...}实现转场?
我是这样弄的:(没用)
pressHandle(){
this.setState({
show:!this.state.show
});
this.transitionHandle();
}
transitionHandle(){
animate(this.refs.box,{
opacity:1
// ....
})
}
【问题讨论】:
-
能否提供
animate()函数是如何实现的?除了 React Native Animated API,我从未听说过 React Native 中的任何纯 JS 动画解决方案。 -
@ThoVu NOT ReactNative,
animate(dom,{},function(){ }),如animate(findDOMNode("#id"),{ opacity:0 },() => { console.log("end") });
标签: javascript reactjs transition