AnimatorResult
Note:
Currently in the beta phase.
Provides the result of component animations, including starting animations, resetting animation parameters, and playing animations in reverse order.
NOTE:
The following APIs require first creating an AnimatorResult object using the createAnimator() method from UIContext, then calling the corresponding methods through this object.
Import Module
import kit.ArkUI.*
class AnimatorResult
public class AnimatorResult {
}
Description: Defines the Animator result type.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
prop onFrame
public mut prop onFrame: (Float64) -> Unit
Description: Callback when a frame is received.
Type: (Float64) -> Unit
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
prop onFinish
public mut prop onFinish: () -> Unit
Description: Callback when the animation completes.
Type: () -> Unit
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
prop onCancel
public mut prop onCancel: () -> Unit
Description: Callback when the animation is canceled.
Type: () -> Unit
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
prop onRepeat
public mut prop onRepeat: () -> Unit
Description: Callback when the animation repeats.
Type: () -> Unit
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func reset(AnimatorOptions)
public func reset(options: AnimatorOptions): Unit
Description: Resets the current animator animation parameters.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Mandatory | Default Value | Description |
|---|---|---|---|---|
| options | AnimatorOptions | Yes | - | Animation options. |
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func play()
public func play(): Unit
Description: Starts the animation. The animation retains the previous playback state, such as the reverse state set during playback, which will be preserved when played again.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func finish()
public func finish(): Unit
Description: Ends the animation, triggering the onFinish callback.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func pause()
public func pause(): Unit
Description: Pauses the animation.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func cancel()
public func cancel(): Unit
Description: Cancels the animation, triggering the onCancel callback. This interface is functionally identical to the finish interface, differing only in the callback triggered. It is recommended to use the finish interface to end animations.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func reverse()
public func reverse(): Unit
Description: Plays the animation in reverse order. This interface is invalid when using the interpolating-spring curve.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
func setExpectedFrameRateRange(ExpectedFrameRateRange)
public func setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange): Unit
Description: Sets the expected frame rate range.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Mandatory | Default Value | Description |
|---|---|---|---|---|
| rateRange | ExpectedFrameRateRange | Yes | - | Frame rate range. |
Exceptions:
-
BusinessException: Corresponding error codes are listed below. For details, see Universal Error Codes.
Error Code ID Error Message 100001 Internal error. Possible causes: The specified page is not found or the object property list is not obtained.
class AnimatorOptions
public class AnimatorOptions {
public var duration: Int32
public var easing: String
public var delay: Int32
public var fill: AnimatorFill
public var direction: AnimatorDirection
public var iterations: Int32
public var begin: Float64
public var end: Float64
public init(
duration!: Int32,
easing!: String,
delay!: Int32,
fill!: AnimatorFill,
direction!: AnimatorDirection,
iterations!: Int32,
begin!: Float64,
end!: Float64
)
}
Description: Defines animation options.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var duration
public var duration: Int32
Description: Duration of the animation playback, in milliseconds.
Type: Int32
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var easing
public var easing: String
Description: Animation interpolation curve.
Type: String
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var delay
public var delay: Int32
Description: Delay time before animation playback starts, in milliseconds.
Type: Int32
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var fill
public var fill: AnimatorFill
Description: Whether to restore to the initial state after animation execution. After execution, the state at the end of the animation (defined in the last keyframe) will be retained.
Type: AnimatorFill
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var direction
public var direction: AnimatorDirection
Description: Animation playback mode.
Type: AnimatorDirection
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var iterations
public var iterations: Int32
Description: Number of animation playback iterations.
Type: Int32
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var begin
public var begin: Float64
Description: Starting point of animation interpolation.
Type: Float64
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
var end
public var end: Float64
Description: Ending point of animation interpolation.
Type: Float64
Access: Read-write
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
init(Int32, String, Int32, AnimatorFill, AnimatorDirection, Int32, Float64, Float64)
public init(
duration!: Int32,
easing!: String,
delay!: Int32,
fill!: AnimatorFill,
direction!: AnimatorDirection,
iterations!: Int32,
begin!: Float64,
end!: Float64
)
Description: Creates an AnimatorOptions object.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Mandatory | Default Value | Description |
|---|---|---|---|---|
| duration | Int32 | Yes | - | Named parameter. Duration of the animation playback, in milliseconds. Value range: [0, +∞). |
| easing | String | Yes | - | Named parameter. Animation interpolation curve. |
| delay | Int32 | Yes | - | Named parameter. Delay time before animation playback starts, in milliseconds. When set to 0, no delay occurs. When set to a negative value, the animation starts early. If the early start time exceeds the total duration, the animation transitions directly to the end. |
| fill | AnimatorFill | Yes | - | Named parameter. Whether to restore to the initial state after animation execution. After execution, the state at the end of the animation (defined in the last keyframe) will be retained. |
| direction | AnimatorDirection | Yes | - | Named parameter. Animation playback mode. |
| iterations | Int32 | Yes | - | Named parameter. Number of animation playback iterations. When set to 0, no playback occurs. When set to -1, playback is infinite. When set to a value greater than 0, it represents the number of playback iterations. |
| begin | Float64 | Yes | - | Named parameter. Starting point of animation interpolation. |
| end | Float64 | Yes | - | Named parameter. Ending point of animation interpolation. |
public enum AnimatorFill <: Equatable<AnimatorFill> {
| None
| Forwards
| Backwards
| Both
| ...
}
Function: The state after animation execution.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parent Type:
- Equatable<AnimatorFill>
None
None
Function: No styles will be applied to the target before or after animation execution.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Forwards
Forwards
Function: After animation ends, the target will retain the state at the end of animation (defined in the last keyframe).
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Backwards
Backwards
Function: During the delay period in AnimatorOptions, the animation will apply values defined in the first keyframe. When the direction in AnimatorOptions is Normal or Alternate, values from the 'from' keyframe are applied; when direction is Reverse or AlternateReverse, values from the 'to' keyframe are applied.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Both
Both
Function: The animation will follow both Forwards and Backwards rules, extending animation properties in both directions.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
operator func !=(AnimatorFill)
public operator func !=(other: AnimatorFill): Bool
Function: Compares whether two enum values are unequal.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| other | AnimatorFill | Yes | - | Another enum value to compare. |
Return Value:
| Type | Description |
|---|---|
| Bool | Returns true if the two enum values are unequal, otherwise returns false. |
operator func ==(AnimatorFill)
public operator func ==(other: AnimatorFill): Bool
Function: Compares whether two enum values are equal.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| other | AnimatorFill | Yes | - | Another enum value to compare. |
Return Value:
| Type | Description |
|---|---|
| Bool | Returns true if the two enum values are equal, otherwise returns false. |
enum AnimatorDirection
public enum AnimatorDirection <: Equatable<AnimatorDirection> {
| Normal
| Reverse
| Alternate
| AlternateReverse
| ...
}
Function: Animation playback mode.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parent Type:
- Equatable<AnimatorDirection>
Normal
Normal
Function: Animation plays forward in a loop.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Reverse
Reverse
Function: Animation plays backward in a loop.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Alternate
Alternate
Function: Animation alternates playback direction, playing forward on odd iterations and backward on even iterations.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
AlternateReverse
AlternateReverse
Function: Animation alternates playback direction in reverse, playing backward on odd iterations and forward on even iterations.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
operator func !=(AnimatorDirection)
public operator func !=(other: AnimatorDirection): Bool
Function: Compares whether two enum values are unequal.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| other | AnimatorDirection | Yes | - | Another enum value to compare. |
Return Value:
| Type | Description |
|---|---|
| Bool | Returns true if the two enum values are unequal, otherwise returns false. |
operator func ==(AnimatorDirection)
public operator func ==(other: AnimatorDirection): Bool
Function: Compares whether two enum values are equal.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| other | AnimatorDirection | Yes | - | Another enum value to compare. |
Return Value:
| Type | Description |
|---|---|
| Bool | Returns true if the two enum values are equal, otherwise returns false. |