WhoBuilt

Animate everything - How to use Animations with 60 fps

Nov 30, 2021· 42 min· 1.9K views·Watch on YouTube

Speaker

Alexander Kuttig of Munich-based software company Horizon explains how to build smooth React Native animations at React Native EU 2021, presented by Callstack.

Give animations a purpose

Kuttig says animations should improve the user experience, not just decorate an app. Examples include showing progress during a three-second press, indicating loading, transforming a scrolling header, and drawing attention to part of a screen.

Why React Native animations can stutter

In the general React Native architecture, JavaScript and native rendering communicate through a bridge. For a scroll animation, values may travel across that bridge every 16 milliseconds; heavy JavaScript work can block interaction and cause dropped frames.

Use Animated for simpler effects

Kuttig recommends React Native's Animated API for straightforward effects such as fades and scroll-linked headers. Enabling the native driver sends animation rules to the native thread, avoiding per-frame trips through JavaScript. The driver supports properties such as opacity and transforms, but not layout changes like height.

Use Lottie for designer-made animations

Lottie plays animation data exported from After Effects with the Bodymovin plugin, and its React Native component can also be controlled by scroll progress. It suits detailed sequences such as avatar animations, especially when a designer can create the animation. Code can control playback, but changing the animation's visual details requires editing the source file.

Use Reanimated for complex, interactive effects

Reanimated 2 uses worklets that run on the UI thread, along with shared values and hooks such as useAnimatedStyle. Kuttig shows scroll-linked effects that can change layout properties such as height, and recommends Reanimated for complex animations requiring developer control. He suggests choosing Lottie when creating the animation in After Effects is faster and full code control is unnecessary.

Takeaways

  • Tie each animation to a user need, such as feedback, progress, or guiding attention.
  • Use the Animated native driver for simpler effects to keep frame calculations off the JavaScript thread.
  • Choose Lottie when a designer can supply a detailed animation and code-level visual control is not needed.
  • Choose Reanimated for complex interactive animations that need UI-thread execution or layout changes.
  • When a project adopts Reanimated for complex work, Kuttig prefers using it for all animations to avoid mixing APIs.

Mentioned in this talk

Search inside this talk

What was claimed 11

Related talks