为什么RN Animated.timing toValue为0没有动画?

时间:2016-03-10 19:58:24

标签: reactjs react-native

我正在使用Animated.timing将幻灯片从0高度动画应用到Animated.View

它与jQuery slideDown动画完全相同。

问题是当我放置fromValuetoValue 0时,它会忽略该值(并显示完整高度)。

如果我放0.01它似乎有用,但我不相信这是最好的解决方案,也许只是一个临时的绑定......

有谁知道为什么要这样做?

_animateIn() {
  Animated.timing(this.state.height, {
    duration: 200,
    toValue: this.props.height,
    fromValue: 0, // works if I put 0.01
  }).start();
};

_animateOut() {
  Animated.timing(this.state.height, {
    duration: 200,
    fromValue: this.props.height,
    toValue: 0, // works if I put 0.01
  }).start();
};

// ...

<Animated.View style={{ height: this.state.height, overflow: 'hidden' }}>
  {children}
</Animated.View>

0 个答案:

没有答案