在 React Native 上使用 Pose 的宽度和高度动画

Width and Height Animation with Pose on React Native

我真的很喜欢在 React Native 上使用 pose 因为它真的很简单。但是我遇到了一些小问题。我的问题是;有什么方法可以在 React Native 上使用 pose 来制作 widthheightpadding 的动画?我用 positionopacitytransform 制作了一些动画,但我无法用 width 弄清楚.

为了更好地理解,我在下面写了一个小示例代码。

示例代码;

import React from 'react';
import posed from 'react-native-pose';
import { View } from 'react-native';

export const SearchBoxAnimated = posed.View({
  getBigger: { x: -16, width: '100%' },
  normal: { x: 0, width: '85%' }
});

const SearchBox = ({isGetBigger}) => (
   <View>
      <SearchBoxAnimated pose={isGetBigger ? 'getBigger' : 'normal'} />
   </View>
);

当我尝试这个时,它给出了一个错误。

Error: Style property 'width' is not supported by native animated module.

包版本:

react native 的主要限制是你只能为非布局属性设置动画,我建议你使用 transform 属性,这在这种情况下可能会起作用。