question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
Introvertuouscommented, Sep 27, 2016

@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>
    )
  }
}

3reactions
mattvotcommented, Sep 1, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Animation - Wikipedia
Animation is a method by which still figures are manipulated to appear as moving images. In traditional animation, images are drawn or painted...
Read more >
Trending animations, motion graphics, and 3D designs
Explore popular animation and motion graphics work from designers on Dribbble, your best resource to connect with designers worldwide.
Read more >
Animaker, Make Animated Videos on Cloud for free
Animaker is an online do-it-yourself (#DIY) animation video maker that brings studio quality presentations within everyone's reach. Animated Videos ...
Read more >
Top 50 Animation Movies and TV Shows - IMDb
A list of the best Animation movies and TV shows, as ranked by IMDb users, like you. Find something great to watch now....
Read more >
CSS Animations - W3Schools
An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found