Hey guys!
I know the svg animations are currently part of the todo list.
Are there some workarounds available though?
I tried to get animations working with react’s AnimatedImplementation
without success.
Filtering out the most rated answers from issues on Github |||||||||||_______|||| Also a sharing corner
Hey guys!
I know the svg animations are currently part of the todo list.
Are there some workarounds available though?
I tried to get animations working with react’s AnimatedImplementation
without success.
Comments are closed.
Hey guys!
I know the svg animations are currently part of the todo list.
Are there some workarounds available though?
I tried to get animations working with react’s AnimatedImplementation
without success.
I’ve successfully implemented an inefficient SVG animation by using an Animated.Value
and animating that using the React Native normal Animated methods.
I then hooked into the changing values by adding an event listener to the value. On each value change you set the state with some style properties that allow the re-rendering of the SVG with the new style.
As said this is inefficient, is noticeable on Android (iOS seems find though…) and is definitely not a long term solution.
@mattvot Did you try wrapping the svg with an Animated.View. I have has some success with that. example (note it is smooth on device, gif is a bit choppy):
class Blarg extends React.Component {
constructor (props) {
super(props);
this.state = {
scale: new Animated.Value(0)
}
this.animate = this.animate.bind(this);
}
componentDidMount() {
this.animate();
}
animate() {
Animated.sequence([
Animated.timing(this.state.scale,
{
toValue:1,
duration:2000
}),
Animated.timing(this.state.scale,
{
toValue:0,
duration:2000
})
]).start(this.animate)
}
render () {
return (
<View>
<Animated.View style={{transform:[{scale:this.state.scale}]}}>
<Svg height="100" width="100">
<Path x='50' y='60' d="M23.70-49.04Q33.40-49.04 39.45-42.10Q45.49-35.16 45.49-23.98Q45.49-12.80 39.45-5.89Q33.40 1.02 23.70 1.02Q13.99 1.02 7.89-5.91Q1.79-12.83 1.79-23.98Q1.79-35.16 7.89-42.10Q13.99-49.04 23.70-49.04M23.70-43.00Q19.76-43.00 17.88-38.34Q16.00-33.68 16.00-23.98Q16.00-14.17 17.86-9.56Q19.72-4.96 23.70-4.96Q27.63-4.96 29.48-9.53Q31.32-14.10 31.32-23.98Q31.32-33.75 29.46-38.37Q27.60-43.00 23.70-43.00Z" stroke="red"/>
</Svg>
</Animated.View>
</View>
)
}
}
Comments are closed.
Copyright © 2022 Fantas...hit
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
I’ve successfully implemented an inefficient SVG animation by using an
Animated.Value
and animating that using the React Native normal Animated methods.I then hooked into the changing values by adding an event listener to the value. On each value change you set the state with some style properties that allow the re-rendering of the SVG with the new style.
As said this is inefficient, is noticeable on Android (iOS seems find though…) and is definitely not a long term solution.
@mattvot Did you try wrapping the svg with an Animated.View. I have has some success with that. example (note it is smooth on device, gif is a bit choppy):