2017-07-01 90 views
0

我目前正在尝试为scrollview设置动画,因此它会调整到上面的一个手风琴的高度。我试图通过使用动画来获取scrollView来抵消,但我不断收到错误转换与“translateY”的键必须是一个数字:{“translateY”:0}。如果我将它包装在Animated.View中,动画不再有效?如何向contentContainerStyle添加动画?

<AnimatedScrollView 
     {...props} 
     onScroll={Animated.event([ 
     { nativeEvent: { contentOffset: { y: this.state.scroll } } }, 
     ])} 
     scrollEventThrottle={16} 
     contentContainerStyle={{ 
     transform: [ 
      { 
      translateY: this.state.contentOffset, 
      }, 
     ], 
     }} 
    > 

回答

0

我有一个类似的问题,我根本没有使用contentContainerStyle解决。我加入了Animated.ScrollView和我原来的滚动型的孩子之间的Animated.View,然后将我的动画风格,以

<Animated.ScrollView> 
    <Animated.View style={animatedStyle}> 
     {/* original scrollview children */} 
    </Animated.View> 
</Animated.ScrollView>