-
I'm trying to animate from a color value with transparency to a color value without transparency, and the result is just the colors going crazy disco mode (they're going through the whole color spectrum). So does
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I also noticed this problem. Example code: import React from 'react';
import { View, Button } from 'react-native';
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
Easing,
interpolateColor,
} from 'react-native-reanimated';
export default function AnimatedStyleUpdateExample() {
const color = useSharedValue(0)
const animatedStyles = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
color.value,
[0, 1, 2],
['rgba(255,0,0,0.1)', 'rgba(0,255,0,0.9)', 'rgba(0,0,255,0.5)'],
// ['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)'],
),
};
});
return (
<View>
<Animated.View style={[{ height: 100, width: 100 }, animatedStyles]} />
<Button onPress={() => {
color.value = withTiming((color.value + 1) % 3, {duration: 1000, easing: Easing.linear})
}} title="click" />
</View>
);
} |
Beta Was this translation helpful? Give feedback.
@mrousavy good point 🙌
I fixed it here.