How does this work
I had a feeling the tangent function would be used for something like this.
Here's the graph of tan(x):
If applied in the right circumstances, it can cause a sort of slow-motion effect. It makes something go really fast, slow down for a bit, then speed back up. That's what's happening here. The size and position for these rectangles is dependent on this function, which causes the zooming effect you see.
You don't really learn how to make these kinds of things, most of it is just tinkering.