问题描述
我有入职和点组成部分。我想在点上插入不透明度动画。但这是行不通的。我是否以错误的方式使用onScroll?感谢任何帮助
const Onboarding = () => {
const { width } = useOrientation();
const scrollX = new Animated.Value(0);
const onScroll = (event: any) => {
Animated.event([{ nativeEvent: { contentOffset: { x: scrollX } } }]);
};
return (
<Box flex={1} backgroundColor="mainBackground">
<Box flex={3}>
<Animated.ScrollView onScroll={onScroll} horizontal>
{slides.map((data,index) => (
<Slide key={index} data={data} {...{ index,scrollX }}
/>
))}
</Animated.ScrollView>
</Box>
<Box
flex={1}
>
{slides.map((_,index) => (
<Dot key={index + 1} currentIndex={divide(scrollX,width)} {...{ index }}
/>
))}
</Box>
</Box>
);
};
const Dot = ({currentIndex,index}:DotProps) => {
const opacity = interpolate(currentIndex,{
inputRange:[index-1,index,index+1],outputRange:[0.5,1,0.5],extrapolate:Extrapolate.CLAMP,})
return (
<Animated.View
style={{ opacity,backgroundColor: "#2CB9B0",width: 8,height: 8,borderRadius: 4
}}
/>
);
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)