Skip to content

Animation System: Making things move #4

@ItsJonQ

Description

@ItsJonQ

This one is an interesting one. It's the most exciting one for me (I like making things move), but arguably, the most difficult. The web is severely lacking when it comes to sequencing animations within UI, especially if it needs to handle mounting/unmounting (and diffing!).

What makes a good animation system?

Animations are hard. Really hard. These complexities are often felt by developers when trying to wrestle various settings and states together. It's more difficult when outside state is involved.

Here are some things that I think make a good animation system:

  • Minimal APIs (e.g. Component props, hooks, etc...)
  • Automatic mount/unmount handling
  • Ability to sequence across multiple items (e.g. staggering items that load)
  • High performance (as little repaint + layout calc as possible)
  • Persisting elements across transitions
  • Seamless animation cancelling
  • Lifecycle hooks (e.g. onEnter, onBeforeLeave)
  • Lightweight (library size. This is... often the killer)

What I've Used

Previously, I've examined and used several libraries and engines, including Anime.js, React Spring, Pose, and others.

There are aspects I like in all of them. However, I've always felt like I had to make considerable (undesirable) trade-offs in one form or another. This often takes the form of overly verbose animation setups.

One library that shows the most potential is Framer Motion.

The APIs for Frame Motion is beautiful. It's very minimal. The provided motion.div components are incredibly intelligent. They know how to respond in isolation and with other animated components in sequence and in context.

The biggest downside (that I can see) is the library's size. It's approx 28-29KB gzipped. Ouch.

However, the feature-set may be worth it 🤞 .


I think when we're ready to experiment with animations, it would be interesting to give Framer Motion a go 👍

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions