Weeknotes № 51-52

Christmas and New Years

In between Christmas and New Years I’ve been slowly making progress on my layout explanations website. Nicholas (the designer) has been putting out different possible designs, and I’ve been trying to implement some of it (both in SwiftUI as well as in my web port).

I also spent a few days trying to figure out what happens when SwiftUI performs animations. I learned a few things:

  • When you start an animation for a property while another animation for that property is already running, the results of these two animations get combined. The combined animation will always have the duration of the new animation. Also, at the end of the (new) animation, the value will be the result of the new animation. In between, these two values get interpolated. I’m hoping to write up some of my experiments soon.

  • When you create multiple transactions (e.g. change one property, animate a change to a second property and then change another property) in one go (e.g. in a button action) these cause SwiftUI to reevaluate the body multiple times (once per transaction). This is necessary to figure out which views should be animated and which should update immediately.

My goal is to understand animations so well that I can reimplement them without problems. I’m planning to also port the animation system to the web, so that I can use them for my visualizations in the layout explanations. Hopefully, at a later point, I can also use that to explain how animations work.

Depending on when you’re reading this: happy new year!