【问题标题】:Pass Direct View Ref To Native Module将 Direct View Ref 传递给本机模块
【发布时间】:2015-10-20 08:17:21
【问题描述】:

我希望实现一个React Native native module,它直接操纵给定的视图引用,即通过使用本机实现的动画对其进行转换。

是否可以将 View 引用传递给本机模块,如果可以,如何做到这一点?

理想情况下,JavaScript API 应该类似于:

var animation = require("NativeModules").animation;

...

animation.foo(this.refs.hello);

如果没有,是否有其他选择,例如使用 Native UI Components

非常感谢

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    啊,所以通过挖掘源代码我找到了UI Manager class

    在本机代码中获取对它的引用,并使用Animation 实现调用.registerAnimation()(还不确定int animationID 的来源!?)。

    动画会直接传入一个View ref,在.run()方法中进行操作。

    Animation 构造函数被传递了一个AnimationPropertyUpdater 实现,它将直接在其方法中影响 View ref。

    所以我想现在我会尝试使用现有的 React Native UI Manager API,因为它在内部拥有 View 层次结构的私有知识。将使用更多发现更新此答案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      • 2017-12-01
      • 2021-05-28
      • 1970-01-01
      • 2012-05-13
      • 1970-01-01
      相关资源
      最近更新 更多