ios - React-Native 不支持的布局动画

标签 ios animation react-native layout-animation

尝试渲染我的场景,其中包含一个 SlideMenu,其中每个项目都会更改我的内容 View ,但出现该错误:

[RCTLog][tid:0x7f8f7054b4b0]
[RCTUIManager.m:466]>Unsupported layout animation createConfig property (null)

我想它来自 SlideMenu 布局的动画,但仅当它在单击其中的项目时触发“片段”(这意味着内容 View )的更改时才会发生。否则菜单会正常关闭。

单击“关闭”时,我的片段显示良好,但我没有看到 SlideMenu 关闭。

我不知道这是来自动画本身还是元素变化和动画结合在一起。

这是我的一些代码:

toggleSlideMenu: function() {
  if (this.state.slideMenuIsAccessible){
    if(this.state.menuIsOpen) {
      //close Menu
    } else {
      //open Menu
    }
    queueAnimation(this.props.animation);
    this.center.setNativeProps({left: this.offset}); //updates UI
  }
});

片段选择发生在 generalTemplate 中:

  matchIdToFragment: function(fragmentId) {
    switch (fragmentId) {
      case 'suggestions':
        return <Suggestions />;
      case 'onScreen':
        return <OnScreen />;
      case 'zap':
        return <Zap setFragmentId={this.props.setFragmentId} setItemId={this.setItemId}/>;
      case 'programDetails':
        return <ProgramDetails itemId={this.state.itemId}/> ;
    }
  },
  render: function() {
    var fragment = this.matchIdToFragment(this.props.fragmentId);

    return (
      <View style={styles.container}>
        <View style={styles.fragmentView}>
          {fragment}
        </View>
        <NavigationBar 
          onOpenUserMenu={this.onOpenUserMenu}
          toggleSlideMenu={this.toggleSlideMenu}/>   
      </View>
    );
  }

按下菜单中的项目会触发菜单的关闭(并将此处未出现的 ID 传输到 generalTemplate :

var Section = React.createClass({
  onPress: function() {
    this.props.toggleSlideMenu();
  },
  render: function() {
    return (
      <TouchableHighlight underlayColor='#DFDFDF' onPress={this.onPress}>
        //Name and icon of the menu item  
      </TouchableHighlight>
    );
  }
});

和动画代码(不确定它是否有用,但我们永远不知道):

var LayoutAnimation = require('react-native').LayoutAnimation;
var DEFAULT_ANIMATION = 'linear';

var animations = {
  layout: {
    linear: {
      duration: 300,
      create: {
        type: LayoutAnimation.Types.linear,
      },
      update: {
        type: LayoutAnimation.Types.linear,
        springDamping: 0.7,
      },
    },
  },
};

var layoutAnimationConfigs = {
  'spring': animations.layout.spring,
};

module.exports = function(animation) {
  var _animation = layoutAnimationConfigs[animation];
  if (!_animation) {
    _animation = layoutAnimationConfigs[DEFAULT_ANIMATION];
  }

  LayoutAnimation.configureNext(_animation);
}

最佳答案

在Github上询问here有人回答我:

我在动画定义的创建部分中缺少一个属性:

create: {
    type: LayoutAnimation.Types.linear,
    property: LayoutAnimation.Properties.opacity,
},

关于ios - React-Native 不支持的布局动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30031874/

相关文章:

ios - 为 iPad 横向创建容器 View 包装?

javascript - 如何在 WebGL 中对对象进行动画处理(修改特定顶点而不是完全变换)

animation - Assimp 动画骨骼变换

MongoDB Realm : TypeError: user. mongoClient 不是函数

android - 无法确定任务 ':app:installDebug' 对 visual studio 代码的 native react 的依赖性

ios - 使用SwiftUI在CanvasView中绘图

ios - 如何获取 iOS 设备型号(例如 A1530)?

css - 加载和页面转换时的 Angular2 动画

react-native - React Native 模态 : Transparent Background & Layout Problem

ios - 如何在 UIAlertController 中使用 UITextView