interpolateColor and withTiming with duration < 250ms dont work in web
See original GitHub issueDescription
When doing a withTiming color animation on web with less than 250 in duration and a scale withSpring animation it reverts to first color on completion
Using interpolateColor function from react-native-reanimated but tested with the one from react-native-redash and same issue
Screenshots
Web example with error

working example on emulator

Steps To Reproduce
Expected behavior
Row should turn green in web
Actual behavior
Row goes back to background color
Snack or minimal code example
here below is the component getting set active on press. Removed other animations for simplicty
export const EmojiButton = ({active, onPress}) => {
const theme = useTheme();
const color = useSharedValue(0);
const scale = useSharedValue(1);
useEffect(() => {
if (active) {
color.value = withTiming(2, {duration: 249, easing: Easing.linear});
scale.value = withSpring(1.2, {stiffness: 400, damping: 10});
} else {
color.value = 0;
scale.value = 1;
}
}, [active]);
const animationStyles = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
color.value,
[0, 1, 2],
[theme.backgroundColor, theme.buttonPressedColor, theme.primaryColor],
),
transform: [
{
scaleY: scale.value,
},
],
};
}, [theme]);
return (
<Pressable onPress={onPress}>
<Animated.View
style={[
{
height: 80,
borderBottomColor: theme.dividerColor,
borderBottomWidth: 1,
},
animationStyles,
]}
/>
</Pressable>
);
};
Package versions
- React: 6.13.1
- React Native: 0.63.3
- React Native Reanimated: react-native-reanimated@2.0.0-alpha.9
- NodeJS: 14.15.0
- react-native-web@0.14.7
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
withTiming | React Native Reanimated
Starts a time based animation. Arguments. toValue [number | string]. The target value at which the animation should conclude. It can be specified...
Read more >How to add animations to your NativeBase App
So, in this tutorial, we will share with you, how to add animations to your NativeBase app, using Reanimated . What are We...
Read more >Reanimated 2 - the new approach to creating animations in ...
We are going to build practical examples of animated sliders using the new Reanimated 2 API and our custom useSlider hook. You don't...
Read more >Interpolate Colors like a pro with React Native Reanimated 2 ...
Your browser can't play this video. ... main concepts we'll explore are: - useDerivedValue - interpolateColor - withTiming Medium article: ...
Read more >Introduction to React Native Reanimated - Prototyped
Your React Native app is not fancy enough? ... Animation helpers like withTiming and withSpring are used to animate the circle.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My PR for
react-native-webwith the fix of this issue is on the roadmap to release RNW. I suppose It’ll be merged within the next release of RNW.The issue is the effect of changes in
react-native-web0.13. The RNW team removedforwardedRefprops. 😔We wait for patch and stay with version 0.12. More information here and here