LayoutAnimation.Types有哪些可用选项

时间:2017-12-22 17:41:52

标签: react-native layout-animation

我有一个来自here的自定义布局动画。

var CustomLayoutAnimation = {
    duration: 200,
    create: {
      type: LayoutAnimation.Types.linear,
      property: LayoutAnimation.Properties.opacity,
    },
    update: {
      type: LayoutAnimation.Types.curveEaseInEaseOut,
    },
  };

运行代码时,我收到以下警告

  

警告:配置类型失败:标记了配置config.update.type   根据{{​​1}}的要求,但其值为   LayoutAnimation.configureNext

代码有一个update.type条目,但警告说它未定义。我猜测,自写入要点以来,允许的值已经更新。 我试图查找可用的允许条目列表,但它们未列在React Native LayoutAnimation documentation中。

我想知道:

  • 语法不再正确吗?
  • 是否有某个网页详细列出了可用类型?

1 个答案:

答案 0 :(得分:3)

每当我遇到这样的问题时,我都会去源代码。 Here's the file for LayoutAnimation.js from the react-native source code。基于此,我在第25行看到allNodes[0].run(moveNodePos, completion: { insert the print statements here } ) TypesEnum声明,如下所示:

const

我怀疑这就是你犯错的原因 - const TypesEnum = { spring: true, linear: true, easeInEaseOut: true, easeIn: true, easeOut: true, keyboard: true, }; 不是受支持的类型。从上面的列表中选择一个,我认为你应该好好去。希望这有帮助!