React Native Modal 不显示动画

yes*_*ded 0 javascript reactjs react-native

所以在我的应用程序中,我有一个工作模态,显示可见性是否设置为 true。它也可以正确关闭并且一切正常(除了错误,如果您重新加载模拟器并且 Modal 处于打开状态,它会保持打开状态并且您无法关闭它)。

我正在使用 react-native-modal 包。

我的问题是动画在模态中不起作用。如果我将值设置为例如“slideInLeft”,则“animationIn”道具不会显示任何更改,“animationOut”道具也不会更改任何内容。

有谁知道为什么会这样?

      <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>

Run Code Online (Sandbox Code Playgroud)

我删减了一些代码以保持简单。如果您遇到相同的问题,我们将不胜感激。

小智 5

确保将 useNativeDriver 道具设置为 true,如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)