Frontend.fyi

Tutorial

Combining scroll-driven animations and SVG path animations to rebuild Apple's pencil draw animation

In this tutorial we will combine an age old technique to animation SVG paths, and combine it with super modern scroll-driven animations to rebuild a beautiful animation.

Try it yourself in our playground

Follow along with the tutorial, or just play around with the code. PRO members can fork this code and save it to their account.

Go Pro

Playgrounds are part of PRO

Frontend.fyi Playgrounds let you take any code example and turn it into a live, editable sandbox — so you can tweak the code, build on it, and learn by doing.

This feature is part of Frontend.fyi PRO, which gives you lifetime access to:

  • Interactive playgrounds (like this one)
  • Full courses (Framer Motion, CSS, and more coming)
  • Copy-paste UI recipes with video walkthroughs
  • Your own public profile to showcase projects and experiments (soon!)

If you're ready to go beyond just watching tutorials and actually build things yourself, PRO is for you.

Last week I came across this Tweet by Wes Bos where he showcased a super neat animation on Apple’s website. I couldn’t stop but notice that Apple still used some JavaScript to pull of this effect, while there is a super modern way to do this with just CSS (see below for browser support).

So I decided this was the perfect opportunity to finally show you all how you can animate SVG paths, and combine it with scroll-driven animations.

A note on browser support

At the time of making this tutorial (july 2024) the animation-timeline is supported in Chromium browsers, with Firefox and Safari working hard on it. In Firefox you can even already experiment with it behind a flag.

Take a look at the diagram below for the latest status.

Eager to learn more?

I think this video might be a good fit for you too!