【问题标题】:Property 'rotateZ' is not supported by native animated module本机动画模块不支持属性“rotateZ”
【发布时间】:2019-09-13 08:54:27
【问题描述】:

我正在尝试在我的 React Native 动画中包含一个旋转。对象应围绕其中心以“2D 方式”旋转。在标准 CSS3 transform 模型中,这将是围绕 Z 轴的旋转。

style.transform = [{
    'rotateZ': animatedValue.interpolate({
        inputRange: [0, 1],
        outputRange: ['0rad', targetAngle + 'rad']
    })
}]

只要我不使用useNativeDriver = true,这段代码就可以正常工作。所以看起来 React Native 确实希望我们使用 rotateZ 以 2D 方式旋转项目。

但是,使用useNativeDriver = true,我得到一个错误:

Property 'rotateZ' is not supported by native animated module

如何使用本机驱动程序进行这种旋转?

【问题讨论】:

    标签: react-native animation react-animated


    【解决方案1】:

    想通了:我需要使用rotate 而不是rotateZ

    这似乎很奇怪,因为 rotateZ 在不使用 useNativeDriver = true 时有效。

    可以在TRANSFORM_WHITELIST constant 中查看 React Native 原生动画驱动程序支持的属性的完整列表。在 React Native 0.60 中,支持以下属性:

    translateX
    translateY
    scale
    scaleX
    scaleY
    rotate
    rotateX
    rotateY
    perspective
    

    看来rotateZhas since been added不见了。

    猜你喜欢
    • 1970-01-01
    • 2011-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多