mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-05 22:56:11 +00:00
# Summary When using the Animated API for animations, it sends the last frame as JavaScript-parsed (matrix) updates in addition to native (transform) updates. ~~As a result, we need to ignore one of them.~~ I believe there's no need to differentiate between native and JavaScript updates—we can simply save both to the same value (mMatrix). By doing so, we can avoid duplicating the transforms. | Before | After | |--------|--------| | <video src="https://github.com/user-attachments/assets/868cc778-4b88-4473-85b5-9665b4b241aa"> | <video src="https://github.com/user-attachments/assets/c6d17b7b-7c9a-47c3-8286-2d9b5720f261"> | ## Test Plan ```jsx import React, {useEffect} from 'react'; import {Animated, useAnimatedValue, View} from 'react-native'; import {Rect, Svg} from 'react-native-svg'; const AnimatedRect = Animated.createAnimatedComponent(Rect); function AnimatedJumpIssue() { const animatedValue = useAnimatedValue(100); return ( <> <View style={{borderColor: 'black', borderWidth: 1}}> <Svg height="100" width="400"> <AnimatedRect x="0" y="0" width="100" height="100" fill="black" transform={[{translateX: animatedValue}]} /> </Svg> </View> <Button title="Press me" onPress={() => { Animated.timing(animatedValue, { toValue: 200, duration: 3000, useNativeDriver: true, }).start(); }} /> </> ); } ``` ## Compatibility | OS | Implemented | | ------- | :---------: | | Android | ✅ | | iOS | ✅ | | macOS | ✅ |