反应本机的动画不透明度取决于滚动位置

时间:2019-09-24 15:58:29

标签: react-native

我想为元素的不透明度设置动画,具体取决于我们滚动到ScrollView的距离,当我们滚动到底部时,不透明度应该为0。 ScrollView的内容大小是动态的。

<Animated.ScrollView 
 onScroll={Animated.event(
      [
        {
          nativeEvent: { contentOffset: { y: scrollY } },
          contentSize: { height: scrollHeight },
          layoutMeasurement: { height: layoutHeight }
        }
      ],
      {
        useNativeDriver: true,
        listener: event => onScroll(event)
      }
    )}>
  <Animated.View style={{opacity: animatedOpacity}}>
</Animated.ScrollView>

由于各种令人沮丧的原因,我的所有方法均无法正常工作。也许有人有可行的解决方案?

0 个答案:

没有答案