From 7525a66e23b122aaed369b6fdc333d77899cbecd Mon Sep 17 00:00:00 2001 From: chenwenchang Date: Sat, 9 Aug 2025 18:55:13 +0800 Subject: [PATCH] adapt animator for 0702 Signed-off-by: chenwenchang --- api/@ohos.animator.d.ts | 110 +++------- api/@ohos.animator.static.d.ets | 355 ++++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+), 78 deletions(-) create mode 100644 api/@ohos.animator.static.d.ets diff --git a/api/@ohos.animator.d.ts b/api/@ohos.animator.d.ts index 7b40c6e1ec..296ec868c8 100644 --- a/api/@ohos.animator.d.ts +++ b/api/@ohos.animator.d.ts @@ -18,11 +18,6 @@ * @kit ArkUI */ -/*** if arkts 1.2 */ -import { FillMode, PlayMode } from './arkui/component/enums'; -import { ExpectedFrameRateRange } from './arkui/component/common'; -/*** endif */ - /** * Defines the animator options. * @interface AnimatorOptions @@ -42,8 +37,7 @@ import { ExpectedFrameRateRange } from './arkui/component/common'; * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ export interface AnimatorOptions { /** @@ -68,8 +62,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ duration: number; @@ -141,8 +134,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ easing: string; @@ -168,8 +160,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ delay: number; @@ -198,8 +189,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ fill: "none" | "forwards" | "backwards" | "both"; @@ -225,8 +215,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ direction: "normal" | "reverse" | "alternate" | "alternate-reverse"; @@ -252,8 +241,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ iterations: number; @@ -279,8 +267,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ begin: number; @@ -306,8 +293,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ end: number; } @@ -318,8 +304,7 @@ export interface AnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ export declare class SimpleAnimatorOptions { /** @@ -330,8 +315,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ constructor(begin: number, end: number); @@ -343,8 +327,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ duration(duration: number): SimpleAnimatorOptions; @@ -370,8 +353,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ easing(curve: string): SimpleAnimatorOptions; @@ -383,8 +365,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ delay(delay: number): SimpleAnimatorOptions; @@ -396,8 +377,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ fill(fillMode: FillMode): SimpleAnimatorOptions; @@ -409,8 +389,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ direction(direction: PlayMode): SimpleAnimatorOptions; @@ -422,8 +401,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ iterations(iterations: number): SimpleAnimatorOptions; } @@ -447,8 +425,7 @@ export declare class SimpleAnimatorOptions { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ export interface AnimatorResult { /** @@ -495,8 +472,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ reset(options: AnimatorOptions): void; @@ -511,8 +487,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ reset(options: AnimatorOptions | SimpleAnimatorOptions): void; @@ -532,8 +507,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ play(): void; @@ -553,8 +527,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ finish(): void; @@ -574,8 +547,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ pause(): void; @@ -595,8 +567,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ cancel(): void; @@ -617,8 +588,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ reverse(): void; @@ -651,8 +621,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ onFrame: (progress: number) => void; @@ -685,8 +654,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ onFinish: () => void; @@ -719,8 +687,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ onCancel: () => void; @@ -753,8 +720,7 @@ export interface AnimatorResult { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ onRepeat: () => void; @@ -763,8 +729,7 @@ export interface AnimatorResult { * @param { ExpectedFrameRateRange } rateRange - Indicates ExpectedFrameRateRange. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange): void; } @@ -787,15 +752,7 @@ export interface AnimatorResult { * @atomicservice * @since 11 */ -/** - * Defines the Animator class. - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @crossplatform - * @atomicservice - * @since 20 - * @arkts 1.1&1.2 - */ -declare class Animator { +export default class Animator { /** * Create an animator object for custom animation. * @param { AnimatorOptions } options - Options. @@ -858,10 +815,7 @@ declare class Animator { * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ static create(options: AnimatorOptions | SimpleAnimatorOptions): AnimatorResult; } - -export default Animator; diff --git a/api/@ohos.animator.static.d.ets b/api/@ohos.animator.static.d.ets new file mode 100644 index 0000000000..3a86f1557c --- /dev/null +++ b/api/@ohos.animator.static.d.ets @@ -0,0 +1,355 @@ +'use static' +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkUI + * @arkts 1.2 + */ + +import { FillMode, PlayMode } from './arkui/component/enums'; +import { ExpectedFrameRateRange } from './arkui/component/common'; + + +/** + * Defines the animator options. + * @interface AnimatorOptions + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export interface AnimatorOptions { + + + /** + * Duration of the animation, in milliseconds. + * The default value is 0. + * @type {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + duration: number; + + + /** + * Time curve of the animation. For details about the supported types. + * linear The animation speed keeps unchanged. + * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0). + * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0). + * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0). + * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0). + * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0). + * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0). + * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0). + * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0). + * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0). + * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0). + * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0). + * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0). + * cubic-bezier(x1, y1, x2, y2) You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1. + * Step curve. The number must be set and only an integer is supported, step-position is optional. It can be set to start or end. The default value is end. + * interpolating-spring(velocity, mass, stiffness, damping), interpolating spring curve. + * The default value is ease. + * @type {string} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + easing: string; + + + /** + * Delay for the animation start. The default value indicates no delay. + * The default value is 0. + * @type {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + delay: number; + + + /** + * Whether to resume to the initial state after the animation is executed. + * none: The initial state is restored after the animation is executed. + * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed. + * @type {"none" | "forwards" | "backwards" | "both"} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + fill: "none" | "forwards" | "backwards" | "both"; + + + /** + * The animation playback mode. + * The default value is "normal". + * @type {"normal" | "reverse" | "alternate" | "alternate-reverse"} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + direction: "normal" | "reverse" | "alternate" | "alternate-reverse"; + + + /** + * Number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations. + * The default value is 1. + * @type {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + iterations: number; + + + /** + * Starting point of animator interpolation. + * The default value is 0. + * @type {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + begin: number; + + + /** + * Ending point of Dynamic Interpolation + * The default value is 1. + * @type {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + end: number; +} +/** + * Defines the SimpleAnimatorOptions class. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare class SimpleAnimatorOptions { + /** + * constructor. + * + * @param { number } begin - Starting point of animator interpolation. + * @param { number } end - Ending point of animator interpolation. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + constructor(begin: number, end: number); + /** + * Set duration of the animation, in milliseconds. + * + * @param { number } duration - if not set, default is 1000. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + duration(duration: number): SimpleAnimatorOptions; + /** + * Set time curve of the animation. For details about the supported types. + * linear The animation speed keeps unchanged. + * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0). + * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0). + * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0). + * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0). + * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0). + * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0). + * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0). + * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0). + * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0). + * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0). + * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0). + * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0). + * cubic-bezier(x1, y1, x2, y2) You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1. + * Step curve. The number must be set and only an integer is supported, step-position is optional. It can be set to start or end. The default value is end. + * @param { string } curve - if not set, default is ease. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + easing(curve: string): SimpleAnimatorOptions; + /** + * Set delay for the animation start. The default value indicates no delay. + * + * @param { number } delay - if not set, default is 0. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + delay(delay: number): SimpleAnimatorOptions; + /** + * Set FillMode of animation. FillMode indicates whether to resume to the initial state after the animation is executed. + * + * @param { FillMode } fillMode - if not set, default is FillMode.Forwards. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + fill(fillMode: FillMode): SimpleAnimatorOptions; + /** + * Set the animation playback mode. + * + * @param { PlayMode } direction - if not set, default is PlayMode.Normal. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + direction(direction: PlayMode): SimpleAnimatorOptions; + /** + * Set number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations. + * + * @param { number } iterations - if not set, default is 1. + * @returns { SimpleAnimatorOptions } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + iterations(iterations: number): SimpleAnimatorOptions; +} + + +/** + * Defines the Animator result interface. + * @interface AnimatorResult + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export interface AnimatorResult { + + + /** + * Reset the options for current animator. + * @param { AnimatorOptions } options - Options. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + *
1. Mandatory parameters are left unspecified. + *
2. Incorrect parameters types. + *
3. Parameter verification failed. + * @throws { BusinessError } 100001 - The specified page is not found or the object property list is not obtained. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + reset(options: AnimatorOptions): void; + /** + * Reset the options for current animator. + * @param { AnimatorOptions | SimpleAnimatorOptions } options - Options. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + *
1. Mandatory parameters are left unspecified. + *
2. Incorrect parameters types. + *
3. Parameter verification failed. + * @throws { BusinessError } 100001 - The specified page is not found or the object property list is not obtained. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + reset(options: AnimatorOptions | SimpleAnimatorOptions): void; + + + /** + * Starts the animation. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + play(): void; + + + /** + * Ends the animation. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + finish(): void; + + + /** + * Pauses the animation. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + pause(): void; + + + /** + * Cancels the animation. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + cancel(): void; + + + /** + * Plays the animation in reverse direction. + * Invalid when using interpolating-spring curve. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + reverse(): void; + /** + * Trigger when vSync callback. + * + * @type { function } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + onFrame: (progress: number) => void; + /** + * The animation is finished. + * + * @type { function } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + onFinish: () => void; + /** + * The animation is canceled. + * + * @type { function } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + onCancel: () => void; + /** + * The animation is repeated. + * + * @type { function } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + onRepeat: () => void; + /** + * The expected frame rate of dynamical of rate range. + * @param { ExpectedFrameRateRange } rateRange - Indicates ExpectedFrameRateRange. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange): void; +} + + + +/** + * Defines the Animator class. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +declare class Animator { + /** + * Create an animator object for custom animation. + * @param { AnimatorOptions | SimpleAnimatorOptions } options - Options. + * @returns { AnimatorResult } animator result + * @throws { BusinessError } 401 - Parameter error. Possible causes: + *
1. Mandatory parameters are left unspecified. + *
2. Incorrect parameters types. + *
3. Parameter verification failed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + static create(options: AnimatorOptions | SimpleAnimatorOptions): AnimatorResult; +} +export default Animator; -- Gitee