Animations
Overview
This page explains the semantics of the animations fields. Public JSON uses camelCase, and enum values follow the spellings in this page.
This page covers only animations. For event-trigger semantics see Events; for node structure see View.
Summary
animations is an optional array that can be attached to any view node (such as container / label / viewScreen); there is no generic
type = "view" node type. Each array item describes one basic declarative animation.
The current implementation supports:
triggers:
manual/mount/show/hideanimation properties:
opacity/x/y/width/height/scale/angle/offsetX/offsetYinteger
from/tofromMode = current: start from the backend's current property value on launchtoMode = relative: compute the end value relative to the resolvedfrombasic easing, delay, repeat, playback
When the backend creates a node, the apply order is: props fields, layout, placement (then the commonProps transform such as zoom / angle / pivot is applied once more), style, debug outline, animations, events, then bindings are subscribed. So when a mount animation starts, the node's initial props, layout, placement, and style are already applied.
Field Table
Key |
Type |
Default |
UI Effect |
Backend Behavior / Limits |
|---|---|---|---|---|
|
string |
|
animation identifier, for resource readability and troubleshooting |
the current backend does not look up, cancel, or dedupe animations by |
|
string enum: |
JSON parsing default |
decides when to start the animation |
|
|
string enum, see Property |
|
decides which UI property the animation changes |
maps to the backend's corresponding property updater |
|
string enum: |
|
how the start value is resolved |
|
|
integer |
|
start value |
used as the backend animation start value; |
|
string enum: |
|
how the end value is resolved |
|
|
integer |
|
end value |
same as |
|
integer ms |
|
forward animation duration |
validator requires non-negative; the backend runs with a non-negative duration |
|
integer ms |
|
start delay |
validator requires non-negative; the backend runs with a non-negative delay |
|
string enum, see Easing |
|
animation curve |
maps to a backend-supported easing |
|
integer |
|
repeat count |
validator requires non-negative |
|
bool |
|
whether to play in reverse |
when true, sets a reverse duration equal to |
Trigger Time (Trigger)
Trigger |
Trigger time |
Current behavior |
|---|---|---|
|
not triggered by the declarative lifecycle |
for runtime APIs such as |
|
when the backend receives and stores the node's animation list |
|
|
after the node's animation list is applied and the node is not currently hidden; or later when |
an initially non-hidden node triggers |
|
later, when |
a node that is hidden from the start does not auto-trigger |
Notes:
if the same node declares both
mountandshowanimations and the node is not initially hidden, both triggers fire one after another during the initial apply phase.show/hidedepend oncommonProps.hiddenstate changes; they do not auto-fire when external code directly changes the backend object's visibility.events such as
click,pressed,valueChangedcan trigger amanualanimation viastartAnimationinevents[].effects; the app can also keep calling the runtime API in the action callback.
Animation Properties (Property)
Property |
|
UI Effect |
Description |
|---|---|---|---|
|
|
change the node's overall opacity |
|
|
px |
change the object's X coordinate |
animation displacement beyond absolute/relative is performed by the backend |
|
px |
change the object's Y coordinate |
same as |
|
px |
change the object's width |
may affect subsequent layout |
|
px |
change the object's height |
may affect subsequent layout |
|
backend transform scale |
change the node's transform scale |
the current numeric semantics use |
|
degree |
change the general node transform rotation |
unit is degrees |
|
px |
change the image content's horizontal offset |
mainly for image nodes, often for scrolling backgrounds |
|
px |
change the image content's vertical offset |
mainly for image nodes |
Currently from / to parse only integers. To use dp or sp, convert them to a bare integer in a constant first and make sure the parser reads a JSON number; the string "24dp" does not work for animation fields.
Value Mode
fromMode and toMode reduce the synchronous readback an app would need before starting an animation:
fromMode = "absolute": use thefromfield.fromMode = "current": read the backend's current property value when the animation starts and use it as the actual start point.toMode = "absolute": use thetofield.toMode = "relative": computeresolvedTo = resolvedFrom + tofrom the actual start point.
fromMode = "relative" and toMode = "current" are currently invalid and raise an error during validator or service parameter parsing.
For example, to move a node up 48px from its current Y coordinate:
{
"property": "y",
"fromMode": "current",
"from": 0,
"toMode": "relative",
"to": -48,
"duration": 200,
"easing": "linear"
}
Easing
JSON value |
Meaning |
|---|---|
|
linear curve |
|
ease in |
|
ease out |
|
ease in and out |
|
overshoot |
|
bounce |
|
step |
An illegal enum raises an error during parsing or validation; AnimationEasing::Max is not allowed through the validator.
Example
The example below demonstrates common entrance animations: the title fades in on mount, and the content container slides in from below to its current position on mount.
{
"type": "viewScreen",
"id": "controls",
"layout": {
"type": "flex",
"gap": "${constant.metrics.pageGap}"
},
"placement": {
"width": "${constant.sizes.match}",
"height": "${constant.sizes.match}"
},
"children": [
{
"type": "label",
"id": "title",
"labelProps": {
"text": "Controls Gallery"
},
"style": {
"font": "${font.title}",
"fontSize": "${constant.metrics.titleFont}",
"textColor": "${constant.colors.primaryText}"
},
"animations": [
{
"id": "title_fade",
"trigger": "mount",
"property": "opacity",
"from": 0,
"to": 255,
"duration": 350,
"easing": "easeOut"
}
]
},
{
"type": "container",
"id": "content",
"animations": [
{
"id": "content_slide",
"trigger": "mount",
"property": "y",
"from": 24,
"to": 0,
"duration": 260,
"easing": "easeOut"
}
]
}
]
}
Show/hide animation example:
{
"type": "container",
"id": "panel",
"commonProps": {
"hidden": true
},
"animations": [
{
"id": "panel_show",
"trigger": "show",
"property": "opacity",
"from": 0,
"to": 255,
"duration": 180,
"easing": "easeOut"
},
{
"id": "panel_hide",
"trigger": "hide",
"property": "opacity",
"from": 255,
"to": 0,
"duration": 120,
"easing": "easeIn"
}
]
}
Current Restrictions
an event effect can reference an animation
idin the node's ownanimations[]viaanimationId; the referenced animation should usetrigger = "manual".idstill does not take part in declarative-lifecycle trigger dedup; it is only a reference identifier in event effect / runtime calls.multiple animations with the same trigger start in array order; if several animations change the same property at once, the final effect depends on backend animation scheduling.
from/to,duration,delay,repeatare all integers; no unit-string parsing.playbackonly sets a reverse duration; it does not separately expose reverse delay, reverse easing, or playback repeat.scaleuses the backend transform scale value, not a percentage or floating-point ratio.