Context
⚠️ Context is still in early development. The current API methods that allow context modifications will be changed or removed in future releases. We plan to move most if all context modification in to the
ListenerAction
s.
The state machine contains Context
maps. The maps allow you to define custom variables that are then used for guarded transtions and in the future dynamic text inside your animations and syncing the frames to outside events like scrolling.
Quick start:
Format
type?: string
Define the type of context variable.
Can be either Numeric
(float), String
or Boolean
.
key?: string
Defines the context variables key.
value?: float | string | bool
Initial value.
Modifying context variables during runtime
Currently context variables are only used within guarded transitions
and have to be manually set. Eventually this will be automatically managed with ListenerActions
that will update the context variables when a gesture is caught.
You can update and modify the three types of context variables by calling the following methods on the dotLottie player :
tmp_set_state_machine_context(key: string, value: f32)
Sets thenumeric
context.tmp_set_state_machine_string_context(key: string, value: string)
Sets thestring
context.tmp_set_state_machine_bool_context(key: string, value: bool)
Sets theboolean
context.
Guarded transitions do work at the moment and will only transition if you set the correct value to the context variable and their condition guard is met.