The Animate Property
- Basic animation
- Animating a code component
- Transform properties
- Colors
- Complex values
- Which properties can you animate?
Basic animation
You already know that you can change a frame’s properties with a code override. For example, you can move, resize, rotate it, change its background color, or do all of it together:


And this will happen instantly.
Well, the same thing happens when you pass those values to the animate
property, only then… animated.
The result in the preview
Whenever you give animate
new values, the frame will animate to those values.
Now, this animation happens immediately, the moment the frame becomes visible. But in the following pages, we’ll also look at how you can trigger it with an event.
Animating a code component
The above example is an override, but in a code component, this works the same:
Obviously, there’s more code here because I’ve also had so set visual and positioning properties. So in upcoming code component examples, I’ll often only show the animation code, like this:
But you can always find the complete code in the example project.
Transform properties
Above I used the left
and top
properties to animate the frame’s position, but it’s actually better to use x
and y
for this. With these, what they call, transform properties, animations will run smoother (GPU accelerated).
They also have the advantage of starting from zero, so moving a frame 10 points to the right is as simple as x: 10
. Other GPU-accelerated transform properties are: scale
, scaleX
, scaleY
, rotate
, rotateX
, rotateY
, skewX
, and skewY
.
Transform origin
These transforms (scaling, rotating, and skewing) will happen from the frame’s transformation origin. By default, this is the center of the frame, but you can change that.
Here I placed the originY
at the top of the frame so that the (x-axis) rotation happens with that edge as the center point.
By the way, I applied some perspective
to the frame’s parent to make the animation look three-dimensional:
Transform origin
transform-origin
perspective
Colors
Just like you can change a frame’s backgroundColor
, you can also animate it. As always, you write the color as a text string, in any of these CSS color formats:
- Hex Code — “#00ff00”
- Websafe Hex Code — “#0f0”
- RGB Decimal — “rgb(0, 255, 0)”
- RGBA Decimal — “rgba(0, 255, 0, 1)” (the last value is ‘alpha’)
- Hue Saturation Lightness — “hsl(120, 100%, 50%)”
- Hue Saturation Lightness Alpha — “hsla(120, 100%, 50%, 1)”
You can also animate between different color formats, like from a HEX to an RGB value.
Pro tip: You can’t animate with CSS named colors like, e.g., “Tomato”.
Supported Values
background
background-color
Complex values
Some CSS values are more complex. For example, a CSS boxShadow
is also written as a string, but this string can contain the shadow’s x- and y-offset, blur, spread, and color.
You can animate all these values simultaneously if you stick to one kind of notation.
Take this code component example:
Its initial shadow (set on style
) is:
Which stands for:
0px
— x-offset-300px
— y-offset80px
— blur radius100px
— spread,- and
rgba(255, 255, 255, .3)
as the color.
… so I had to animate to a shadow defined with the same five values:
Animating to a shadow written in the shorter ‘just x- and y-offset and color’ form (also possible in CSS) would not work.
Supported Values, style
boxShadow
Which properties can you animate?
A bun