Experiments with High Performance Animation in React Native

Three major methods for shape animation with React Native via @salesforceeng

  • This story is my experience and experiments to achieve high performance animation in React Native.Along the way I learned tons from these blogs and recommend you read them as you dive deeper into building your own animations in React Native:React Native Animations Using Animated API from Nader DabitReact Native ART and D3 from Harry WolffBefore we continue, I would like to define what “high performance animation” in terms of my project.
  • Note: There is another OpenGL binding for React Native which enables a more flexible OpenGL implementation without the interface.Animation in React NativeIn my exploration I tested three major methods (with some variations) for doing shape animation with React Native.
  • For example, if we have a shape with a 1px border, it cannot be transformed to have a larger width/height and retain the same border width without redrawing.Experiments and ResultsRequest Animation Frame + JavaScript tweeningThe first approach is to change nothing but use the same code from the web implementation — meaning everything is done in JavaScript without any help from React Native.
  • The gaps between each country will also get scaled so the transformed shapes are not the same as the new shapes.Zoom animation with fade in/outThis method has a significant impact on the memory footprint since there are two views with a shadow node per shape.Animated + Hybrid Native Driver + Animated Shape (ART)For this approach I still used the Native Driver while I found there is a trick to communicate between the JS thread and UI thread using setNativeProps.
  • I first tried with React Native ART and switched to React Native SVG while both give similar results.Animated + Hybrid Native Driver + Animated Shape (OpenGL)After realizing the bottleneck comes from re-drawing shapes, I switched to another library which has the drawing logic implemented in OpenGL.

Archiving decent animation performance is quite tricky. This story is my experience and experiments to achieve high performance animation in React Native.
Continue reading “Experiments with High Performance Animation in React Native”

React Native animations revisited — Part III – Blog @ Callstack.io

  • I hope that makes all the stuff related to animations a bit easier for you.
  • If we want to respond to screen gestures, and apply some animation as well (ie.
  • Now we only need to clear responder when unmounting component, and attach animation styles (which we already know!
  • First two functions are just used to ask to be responder, onPanResponderGrant() is invoked when responder is granted to our component, onPanResponderMove() is called every time component moves, and in onPanResponderRelease() you can tell what to do after finger is released.
  • React Native animations revisited – Part III

Animations are really important part of modern applications. But sometimes animation is not enough. If we want to respond to screen gestures, and apply some animation as well (ie. create drag and…
Continue reading “React Native animations revisited — Part III – Blog @ Callstack.io”

React Native Animations Using the Animated API – React Native Training – Medium

#ReactNative Animations Using the Animated #API:  by @dabit3 #JavaScript #iOS #Android

  • We render a main View with three Animated.
  • Is the final code for this animation with a working example.
  • If the animation is done because it finished running normally, the completion callback will be invoked with {finished: true}, but if the animation is done because stop was called on it before it could finish (e.g. because it was interrupted by a gesture or another animation), then it will receive {finished: false}.
  • In the animate method, we set the values of all three animated values back to zero.
  • Animated.sequence() – Starts an array of animations in order, waiting for each to complete before starting the next.

We will be covering Animated.timing() and Animated.spring() as they are the most useful in my experience. Along with these three Animated methods, there are three ways to call these animations along…
Continue reading “React Native Animations Using the Animated API – React Native Training – Medium”

React Native Animations Using the Animated API – React Native Training – Medium

#ReactNative Animations Using the Animated #API:   by @dabit3 #JavaScript #iOS #Android

  • We render a main View with three Animated.
  • Is the final code for this animation with a working example.
  • If the animation is done because it finished running normally, the completion callback will be invoked with {finished: true}, but if the animation is done because stop was called on it before it could finish (e.g. because it was interrupted by a gesture or another animation), then it will receive {finished: false}.
  • In the animate method, we set the values of all three animated values back to zero.
  • Animated.sequence() – Starts an array of animations in order, waiting for each to complete before starting the next.

We will be covering Animated.timing() and Animated.spring() as they are the most useful in my experience. Along with these three Animated methods, there are three ways to call these animations along…
Continue reading “React Native Animations Using the Animated API – React Native Training – Medium”

React Native Animations Using the Animated API – React Native Training – Medium

#ReactNative Animations Using the Animated #API:  by @dabit3 #JavaScript #iOS #Android

  • We render a main View with three Animated.
  • Is the final code for this animation with a working example.
  • If the animation is done because it finished running normally, the completion callback will be invoked with {finished: true}, but if the animation is done because stop was called on it before it could finish (e.g. because it was interrupted by a gesture or another animation), then it will receive {finished: false}.
  • In the animate method, we set the values of all three animated values back to zero.
  • Animated.sequence() – Starts an array of animations in order, waiting for each to complete before starting the next.

We will be covering Animated.timing() and Animated.spring() as they are the most useful in my experience. Along with these three Animated methods, there are three ways to call these animations along…
Continue reading “React Native Animations Using the Animated API – React Native Training – Medium”

React Native Animations Using the Animated API – React Native Training – Medium

#ReactNative Animations Using the Animated #API:  by @dabit3 #JavaScript #iOS #Android

  • We render a main View with three Animated.
  • Is the final code for this animation with a working example.
  • If the animation is done because it finished running normally, the completion callback will be invoked with {finished: true}, but if the animation is done because stop was called on it before it could finish (e.g. because it was interrupted by a gesture or another animation), then it will receive {finished: false}.
  • In the animate method, we set the values of all three animated values back to zero.
  • Animated.sequence() – Starts an array of animations in order, waiting for each to complete before starting the next.

We will be covering Animated.timing() and Animated.spring() as they are the most useful in my experience. Along with these three Animated methods, there are three ways to call these animations along…
Continue reading “React Native Animations Using the Animated API – React Native Training – Medium”

react-native-maps

  • Default markers will be rendered unless a custom marker is specified.
  • Callouts to markers can be completely arbitrary react views, similar to markers.
  • Marker views can use the animated API to enhance the effect.
  • Markers can be customized by just using images, and specified using the image prop.
  • Issue: Since android needs to render its marker views as a bitmap, the animations APIs may not be compatible with the Marker views.

React Native Mapview component for iOS + Android
Continue reading “react-native-maps”