Javascript 是否可以使用React Native中的动画设置模态动画?
我试图使我的模态在点击按钮时向上滑动并反弹,但当我将模态包装到动画的.View组件中时,它不起作用。它只是因为animationType道具而向上滑动,但之后什么也没有发生。有什么想法吗Javascript 是否可以使用React Native中的动画设置模态动画?,javascript,ios,animation,reactjs,react-native,Javascript,Ios,Animation,Reactjs,React Native,我试图使我的模态在点击按钮时向上滑动并反弹,但当我将模态包装到动画的.View组件中时,它不起作用。它只是因为animationType道具而向上滑动,但之后什么也没有发生。有什么想法吗 //in render() function <Animated.View style={{ flex: 1, transform: [ // `transform` is an ordered array
//in render() function
<Animated.View
style={{
flex: 1,
transform: [ // `transform` is an ordered array
{ scale: this.state.bounceValue }, // Map `bounceValue` to `scale`
],
}}
>
<Modal
animationType={"slide"}
transparent={true}
visible={this.state.modalVisible}
>
<View style={styles.modalContainer}>
<View style={styles.modalInnerContainer}>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
/>
</View>
</View>
</Modal>
</Animated.View>
// onPress function
_onSelectFilter(rowID) {
if (this.state.modalVisible) {
this.state.bounceValue.setValue(2);
Animated.spring(
this.state.bounceValue,
{
toValue: 0.8,
friction: 1,
}
).start();
}
}
//在render()函数中
//onPress函数
_onSelectFilter(rowID){
if(this.state.modalVisible){
this.state.bounceValue.setValue(2);
春天(
this.state.bounceValue,
{
toValue:0.8,
摩擦:1,,
}
).start();
}
}
文档中并不完全清楚,但是React Native中的
包含在与主React Native容器分离的本机级视图中。这意味着你没有太多的控制权
如果需要附加控件,则需要使用顶级视图,而不是
如果你的应用程序很简单,你可以简单地添加一个在根级别具有绝对定位的视图
// Modal content goes inside here
<View style={{position: 'absolute', top: 0, right: 0, bottom: 0, left: 0}}>
</View>
//模态内容放在这里
对于更复杂的应用程序,您可能希望将其集成到您的策略中 我发现了另一个完全是JS(react native modalbox)的第三方模块,它是完全可定制的!