typedef struct {...} ArkUI_NativeAnimateAPI_1 Declares a set of animation APIs of ArkUI on the native side.
Since: 12
Related module: ArkUI_NativeModule
Header file: native_animate.h
| Name | Description |
|---|---|
| int32_t (*animateTo)(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update, ArkUI_AnimateCompleteCallback* complete) | Triggers an explicit animation. |
| int32_t (*keyframeAnimateTo)(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option) | Triggers a keyframe animation. |
| ArkUI_AnimatorHandle (*createAnimator)(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option) | Creates an animator animation object and returns its pointer (the caller obtains the ownership of the object). |
| void (*disposeAnimator)(ArkUI_AnimatorHandle animatorHandle) | Disposes of the animator animation object pointed to by the passed-in pointer and releases its memory. The pointer cannot be used again after disposal. |
int32_t (*animateTo)(ArkUI_ContextHandle context, ArkUI_AnimateOption* option, ArkUI_ContextCallback* update, ArkUI_AnimateCompleteCallback* complete)
Description
Performs an explicit animation transition effect.
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle context | UI context instance, which is used to specify the UI context where the animation resides. It must not be NULL. |
| ArkUI_AnimateOption* option | Pointer to the animation effect option. It must not be NULL. |
| ArkUI_ContextCallback* update | Pointer to the closure function for the animation effect. The system automatically inserts a transition animation for state changes that occur within the closure function. The parameter must not be NULL. Note: The component attributes to be set in the closure function must have been set on the component before animateTo is called. |
| ArkUI_AnimateCompleteCallback* complete | Pointer to the callback invoked when the animation playback is complete. If NULL is passed, no completion callback notification is set. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Check the type and validity of the passed parameters. Possible causes: context is invalid or option is set to NULL or is set improperly. Solution: ensure that context is valid and option is set correctly and not to NULL. |
int32_t (*keyframeAnimateTo)(ArkUI_ContextHandle context, ArkUI_KeyframeAnimateOption* option)
Description
Defines a keyframe animation. By specifying keyframes to define the values of attributes at different time points, the system automatically calculates the attribute values of intermediate frames based on the interpolation algorithm to achieve smooth transitions. For details about the keyframe parameter configuration, see ArkUI_KeyframeAnimateOption. Unlike the explicit transition animation of animateTo, keyframeAnimateTo is suitable for scenarios where different animation states need to be defined at multiple time points. You can use animateTo when only a transition animation from the start state to the end state is required, and use keyframeAnimateTo when fine-grained control of the animation process through multiple keyframes is required.
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle context | UI context instance, which is used to specify the UI context where the keyframe animation resides. It must not be NULL. |
| ArkUI_KeyframeAnimateOption* option | Pointer to the keyframe animation option, which is used to specify the parameter of the keyframe animation, including the time point, animation attribute value, and transition effect. It must not be NULL. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Check the type and validity of the passed parameters. Possible causes: context is invalid or option is set to NULL or is set improperly. Solution: ensure that context is valid and option is set correctly and not to NULL. |
ArkUI_AnimatorHandle (*createAnimator)(ArkUI_ContextHandle context, ArkUI_AnimatorOption* option)
Description
Creates an animator animation object and returns its pointer. Unlike the trigger-based animation of animateTo/keyframeAnimateTo, createAnimator creates a persistently controllable animation object, which is suitable for scenarios requiring fine-grained control such as repeated starting, stopping, and state listening. You can use animateTo or keyframeAnimateTo for one-time transition animations, and use createAnimator when persistent control of the animation lifecycle is required.
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle context | UI context instance, which is used to specify the UI context where the animation resides. It must not be NULL. |
| ArkUI_AnimatorOption* option | Pointer to the animator animation option, which must not be NULL. |
Returns
| Type | Description |
|---|---|
| ArkUI_AnimatorHandle | Pointer to the animator animation object, which is used to control the animation object subsequently. NULL is returned when the function parameter is invalid. |
void (*disposeAnimator)(ArkUI_AnimatorHandle animatorHandle)
Description
Disposes of the animator animation object and releases its memory. After the disposal, the handle must not be used again. When NULL or a handle that has been destroyed is passed, the API does not perform the disposal operation.
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator animation object, which must be a valid handle created by createAnimator. It must not be an object that has been disposed of. |