DOCS·TUTORIAL

Steps

Steps

So far, your animation types one piece of code.

But the best way to explain code is often to show it changing: a refactor, a bug fix, a feature added line by line.

That's what Steps are for.

A step is one version of your code. The first step is typed out. Then each later step animates from the one before it.

Add a step

Continue with the code from First Steps, the get_user() function in users.py.

In the Code panel, above your code, you will see this:

The Steps card in the Code panel, with the Add a step button

Click Add a step.

Now there are two numbered tabs, 1 and 2, and you are on step 2.

Step 2 starts as a copy of step 1, so you only have to write what changes.

Change the code

Let's add type hints and a timeout.

Edit the code of step 2 so that lines 6 and 7 look like this:

users.py: step 2 adds type hints and a timeout

The code of step 2, as text
import requests

API = "https://api.example.com"


def get_user(user_id: int) -> dict:
    response = requests.get(f"{API}/users/{user_id}", timeout=10)
    return response.json()

The preview shows the step you are editing:

The editor on step 2, with the step tabs, the step's buttons, and the new code in the preview

Add one more

Now click Add step, next to the tabs.

The new step goes right after the one you are on, and again starts as a copy of it.

Add one more line, line 8, to raise an error when the request fails:

users.py: step 3 raises an error when the request fails

The code of step 3, as text
import requests

API = "https://api.example.com"


def get_user(user_id: int) -> dict:
    response = requests.get(f"{API}/users/{user_id}", timeout=10)
    response.raise_for_status()
    return response.json()

You now have three steps:

The Code panel with three step tabs, and the Effect, Speed and Focus lines controls of step 3

Play it

Press play.

Step 1 is typed out, as before. Then the code morphs into step 2, and then into step 3.

This is the animation you just built, playing right here:

users.py: three steps, each morphing into the next

Notice what happens in each change:

  • Code that didn't change stays where it is.
  • Code that moved glides to its new place.
  • Code that was removed fades out.
  • New code fades in.

So your viewers' eyes go straight to what changed. ✨

Tip

Above the scrubber there is one dot for each step. Click a dot to jump to that step.

Move, duplicate and delete

Under the tabs there's a row of buttons for the step you are on:

  • The arrows move the step earlier or later.
  • Duplicate makes a copy of the step right after it, with the same effect, speed and focus.
  • Delete removes it.

If you delete a step by mistake, click Undo. You have a few seconds to do it.

An animation can have up to 12 steps.

Free and Pro

Building and previewing steps is free, and so is exporting a PNG of the step on screen.

Taking the whole multi-step animation out of the editor, as a GIF, an MP4, a link or an embed, is part of Pro. That's what the PRO mark next to the tabs means.

Recap

Now you know how to:

  • Add steps, each one a new version of your code.
  • Edit a step and see it in the preview.
  • Play the whole sequence, and jump between steps.
  • Move, duplicate and delete steps.

Morphing is only one of the ways a step can arrive. Next, you will choose others, in Effects, Focus and Timing.