Javascript 反应本机模态不';不显示动画
因此,在我的应用程序中,我有一个工作模式,显示可见性是否设置为true。它也能正确关闭,一切正常(除了一个bug,如果你重新加载模拟器,模态打开,它会保持打开状态,你不能关闭它) 我使用的是react原生模式包 我的问题是动画在模式中不起作用。 如果我将值例如设置为“slideInLeft”,则“animationIn”道具不会显示任何更改,“animationOut”道具也不会更改任何内容 有人知道为什么会这样吗Javascript 反应本机模态不';不显示动画,javascript,reactjs,react-native,Javascript,Reactjs,React Native,因此,在我的应用程序中,我有一个工作模式,显示可见性是否设置为true。它也能正确关闭,一切正常(除了一个bug,如果你重新加载模拟器,模态打开,它会保持打开状态,你不能关闭它) 我使用的是react原生模式包 我的问题是动画在模式中不起作用。 如果我将值例如设置为“slideInLeft”,则“animationIn”道具不会显示任何更改,“animationOut”道具也不会更改任何内容 有人知道为什么会这样吗 <View> <Modal
<View>
<Modal
isVisible={this.props.visible}
onBackButtonPress={this.props.toggle}
animationIn="slideInLeft"
animationOut="slideOutRight"
>
<View style={modalStyle.container}>
<View style={modalStyle.headerText}>
<Text style={{ textAlign: "center", color: "black",
fontWeight:"bold" }}>
Projectbrowser
</Text>
</View>
{ SOME MORE CODE IN BETWEEN HERE }
</View>
</Modal>
</View>
项目浏览器
{此处之间还有一些代码}
我删去了一些代码以保持简单。如果您遇到相同的问题,欢迎进行任何修复和升级 您可以在此模式中使用这行代码
animationType="slide"
此动画道具将有助于将模态视图设置为幻灯片格式的动画
这对我很有帮助,你可以像
<Modal
animationType="slide"
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {
Alert.alert('Modal has been closed.');
}}>
{
警报。警报('模式已关闭');
}}>
您可以在此模式中使用这行代码
animationType="slide"
此动画道具将有助于将模态视图设置为幻灯片格式的动画
这对我很有帮助,你可以像
<Modal
animationType="slide"
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {
Alert.alert('Modal has been closed.');
}}>
{
警报。警报('模式已关闭');
}}>
我在这里分享世博快餐链接,请检查这一链接是否正常。我已经演示了你的问题
检查一下,让我知道。我刚刚在状态中更改了你的道具,并基于TouchableOpacity更改了它的值
Example.js
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {visible:false,toggle:false}}
render() {
return (
<View>
<View>
<Modal
isVisible={this.state.visible}
onBackButtonPress={this.state.toggle}
animationIn="slideInLeft"
animationOut="slideOutRight"
>
<View style={{width:100,height:200}}>
<View style={{}}>
<Text style={{ textAlign: "center", color: "black",
fontWeight:"bold" }}>
Projectbrowser
</Text>
<TouchableOpacity style={{width:"10%",height:"10%",backgroundColor:"red",justifyContent:"center",alignItems:"center"}} onPress={()=>this.setState({visible:false})}>
<Text>Press me</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
</View>
<TouchableOpacity style={{width:"20%",height:"80%",bottom:150,alignItems:"center"}} onPress={()=>this.setState({visible:true})}>
<Text>Press me</Text>
</TouchableOpacity>
</View>
);
}
}
导出默认类App扩展React.Component{
建造师(道具){
超级(道具);
this.state={visible:false,toggle:false}
render(){
返回(
项目浏览器
this.setState({visible:false}}>
按我
this.setState({visible:true}}>
按我
);
}
}
我在这里分享世博快餐链接,请检查这一链接是否正常。我已经演示了你的问题
检查一下,让我知道。我刚刚在状态中更改了你的道具,并基于TouchableOpacity更改了它的值
Example.js
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {visible:false,toggle:false}}
render() {
return (
<View>
<View>
<Modal
isVisible={this.state.visible}
onBackButtonPress={this.state.toggle}
animationIn="slideInLeft"
animationOut="slideOutRight"
>
<View style={{width:100,height:200}}>
<View style={{}}>
<Text style={{ textAlign: "center", color: "black",
fontWeight:"bold" }}>
Projectbrowser
</Text>
<TouchableOpacity style={{width:"10%",height:"10%",backgroundColor:"red",justifyContent:"center",alignItems:"center"}} onPress={()=>this.setState({visible:false})}>
<Text>Press me</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
</View>
<TouchableOpacity style={{width:"20%",height:"80%",bottom:150,alignItems:"center"}} onPress={()=>this.setState({visible:true})}>
<Text>Press me</Text>
</TouchableOpacity>
</View>
);
}
}
导出默认类App扩展React.Component{
建造师(道具){
超级(道具);
this.state={visible:false,toggle:false}
render(){
返回(
项目浏览器
this.setState({visible:false}}>
按我
this.setState({visible:true}}>
按我
);
}
}
请确保将true设置为useNativeDriver道具,如下所示:
<View>
<Modal
isVisible={this.props.visible}
onBackButtonPress={this.props.toggle}
animationIn="slideInLeft"
animationOut="slideOutRight"
useNativeDriver={true} // try adding This line
>
<View style={modalStyle.container}>
<View style={modalStyle.headerText}>
<Text style={{ textAlign: "center", color: "black",
fontWeight:"bold" }}>
Projectbrowser
</Text>
</View>
{ SOME MORE CODE IN BETWEEN HERE }
</View>
</Modal>
</View>
项目浏览器
{此处之间还有一些代码}
请确保将true设置为useNativeDriver道具,如下所示:
<View>
<Modal
isVisible={this.props.visible}
onBackButtonPress={this.props.toggle}
animationIn="slideInLeft"
animationOut="slideOutRight"
useNativeDriver={true} // try adding This line
>
<View style={modalStyle.container}>
<View style={modalStyle.headerText}>
<Text style={{ textAlign: "center", color: "black",
fontWeight:"bold" }}>
Projectbrowser
</Text>
</View>
{ SOME MORE CODE IN BETWEEN HERE }
</View>
</Modal>
</View>
项目浏览器
{此处之间还有一些代码}
出于某种原因,animationType可以使用幻灯片,但它不是从软件包中下载的,因此它在黑色背景中滑动,然后我的实际模式加载正常但非常缓慢。animationType对react-native-modal不起作用。它可能确实起作用,因为它从底部滑入,但整体速度非常慢。modal大约在5秒后出现,但如果没有animationType,它也很慢,因此可能是因为模拟器速度慢。谢谢,我会更深入地研究它。模拟器,这也许就是为什么它这么慢的原因。出于某种原因,animationType与幻灯片一起工作,但它不是来自软件包,所以它在黑色背景中滑动,然后我的实际模态加载正常,但非常慢。animationType对react-native-modal不起作用。它可能确实起作用,因为它从底部滑入,但整体速度非常慢。modal大约在5秒后出现,但如果没有animationType,它也很慢,因此可能是因为模拟器速度慢。谢谢,我会更深入地研究它。模拟器,也许这就是为什么它这么慢的原因。我只渲染了一个白色屏幕,世博会快餐没有为我加载。世博会仍然不起作用,示例也不起作用,我在“动画”或“输出”中输入的任何内容都不会改变任何内容。我只渲染了一个白色屏幕,世博会零食没有为我加载。世博会仍然不起作用,示例也不起作用,我在“动画”或“输出”中输入的任何东西都不会改变任何东西。谢谢,伙计,我的模态出现了一些抖动和滞后,这修复了我的问题。伙计,我的模态出现了一些抖动和滞后,这修复了我的问题