• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * Defines the animator options.
23 * @interface AnimatorOptions
24 * @syscap SystemCapability.ArkUI.ArkUI.Full
25 * @since 6
26 */
27/**
28 * Defines the animator options.
29 * @interface AnimatorOptions
30 * @syscap SystemCapability.ArkUI.ArkUI.Full
31 * @crossplatform
32 * @since 10
33 */
34/**
35 * Defines the animator options.
36 * @interface AnimatorOptions
37 * @syscap SystemCapability.ArkUI.ArkUI.Full
38 * @crossplatform
39 * @atomicservice
40 * @since 11
41 */
42export interface AnimatorOptions {
43  /**
44   * Duration of the animation, in milliseconds.
45   * The default value is 0.
46   * @type {number}
47   * @syscap SystemCapability.ArkUI.ArkUI.Full
48   * @since 6
49   */
50  /**
51   * Duration of the animation, in milliseconds.
52   * The default value is 0.
53   * @type {number}
54   * @syscap SystemCapability.ArkUI.ArkUI.Full
55   * @crossplatform
56   * @since 10
57   */
58  /**
59   * Duration of the animation, in milliseconds.
60   * The default value is 0.
61   * @type {number}
62   * @syscap SystemCapability.ArkUI.ArkUI.Full
63   * @crossplatform
64   * @atomicservice
65   * @since 11
66   */
67  duration: number;
68
69  /**
70   * Time curve of the animation. For details about the supported types.
71   * linear The animation speed keeps unchanged.
72   * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0).
73   * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0).
74   * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0).
75   * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0).
76   * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0).
77   * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0).
78   * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0).
79   * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0).
80   * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0).
81   * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0).
82   * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0).
83   * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0).
84   * 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.
85   * 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.
86   * The default value is ease.
87   * @type {string}
88   * @syscap SystemCapability.ArkUI.ArkUI.Full
89   * @since 6
90   */
91  /**
92   * Time curve of the animation. For details about the supported types.
93   * linear The animation speed keeps unchanged.
94   * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0).
95   * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0).
96   * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0).
97   * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0).
98   * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0).
99   * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0).
100   * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0).
101   * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0).
102   * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0).
103   * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0).
104   * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0).
105   * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0).
106   * 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.
107   * 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.
108   * The default value is ease.
109   * @type {string}
110   * @syscap SystemCapability.ArkUI.ArkUI.Full
111   * @crossplatform
112   * @since 10
113   */
114  /**
115   * Time curve of the animation. For details about the supported types.
116   * linear The animation speed keeps unchanged.
117   * ease The animation starts and ends at a low speed, cubic-bezier(0.25, 0.1, 0.25, 1.0).
118   * ease-in The animation starts at a low speed, cubic-bezier(0.42, 0.0, 1.0, 1.0).
119   * ease-out The animation ends at a low speed, cubic-bezier(0.0, 0.0, 0.58, 1.0).
120   * ease-in-out The animation starts and ends at a low speed, cubic-bezier(0.42, 0.0, 0.58, 1.0).
121   * fast-out-slow-in Standard curve, cubic-bezier(0.4, 0.0, 0.2, 1.0).
122   * linear-out-slow-in Deceleration curve, cubic-bezier(0.0, 0.0, 0.2, 1.0).
123   * fast-out-linear-in Acceleration curve, cubic-bezier(0.4, 0.0, 1.0, 1.0).
124   * friction Damping curve, cubic-bezier(0.2, 0.0, 0.2, 1.0).
125   * extreme-deceleration Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0).
126   * sharp Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0).
127   * rhythm Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0).
128   * smooth Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0).
129   * 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.
130   * 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.
131   * interpolating-spring(velocity, mass, stiffness, damping), interpolating spring curve.
132   * The default value is ease.
133   * @type {string}
134   * @syscap SystemCapability.ArkUI.ArkUI.Full
135   * @crossplatform
136   * @atomicservice
137   * @since 11
138   */
139  easing: string;
140
141  /**
142   * Delay for the animation start. The default value indicates no delay.
143   * The default value is 0.
144   * @type {number}
145   * @syscap SystemCapability.ArkUI.ArkUI.Full
146   * @since 6
147   */
148  /**
149   * Delay for the animation start. The default value indicates no delay.
150   * The default value is 0.
151   * @type {number}
152   * @syscap SystemCapability.ArkUI.ArkUI.Full
153   * @crossplatform
154   * @since 10
155   */
156  /**
157   * Delay for the animation start. The default value indicates no delay.
158   * The default value is 0.
159   * @type {number}
160   * @syscap SystemCapability.ArkUI.ArkUI.Full
161   * @crossplatform
162   * @atomicservice
163   * @since 11
164   */
165  delay: number;
166
167  /**
168   * Whether to resume to the initial state after the animation is executed.
169   * none: The initial state is restored after the animation is executed.
170   * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed.
171   * @type {"none" | "forwards" | "backwards" | "both"}
172   * @syscap SystemCapability.ArkUI.ArkUI.Full
173   * @since 6
174   */
175  /**
176   * Whether to resume to the initial state after the animation is executed.
177   * none: The initial state is restored after the animation is executed.
178   * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed.
179   * @type {"none" | "forwards" | "backwards" | "both"}
180   * @syscap SystemCapability.ArkUI.ArkUI.Full
181   * @crossplatform
182   * @since 10
183   */
184  /**
185   * Whether to resume to the initial state after the animation is executed.
186   * none: The initial state is restored after the animation is executed.
187   * forwards: The state at the end of the animation (defined in the last key frame) is retained after the animation is executed.
188   * @type {"none" | "forwards" | "backwards" | "both"}
189   * @syscap SystemCapability.ArkUI.ArkUI.Full
190   * @crossplatform
191   * @atomicservice
192   * @since 11
193   */
194  fill: "none" | "forwards" | "backwards" | "both";
195
196  /**
197   * The animation playback mode.
198   * The default value is "normal".
199   * @type {"normal" | "reverse" | "alternate" | "alternate-reverse"}
200   * @syscap SystemCapability.ArkUI.ArkUI.Full
201   * @since 6
202   */
203  /**
204   * The animation playback mode.
205   * The default value is "normal".
206   * @type {"normal" | "reverse" | "alternate" | "alternate-reverse"}
207   * @syscap SystemCapability.ArkUI.ArkUI.Full
208   * @crossplatform
209   * @since 10
210   */
211  /**
212   * The animation playback mode.
213   * The default value is "normal".
214   * @type {"normal" | "reverse" | "alternate" | "alternate-reverse"}
215   * @syscap SystemCapability.ArkUI.ArkUI.Full
216   * @crossplatform
217   * @atomicservice
218   * @since 11
219   */
220  direction: "normal" | "reverse" | "alternate" | "alternate-reverse";
221
222  /**
223   * Number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations.
224   * The default value is 1.
225   * @type {number}
226   * @syscap SystemCapability.ArkUI.ArkUI.Full
227   * @since 6
228   */
229  /**
230   * Number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations.
231   * The default value is 1.
232   * @type {number}
233   * @syscap SystemCapability.ArkUI.ArkUI.Full
234   * @crossplatform
235   * @since 10
236   */
237  /**
238   * Number of times the animation will be played. number indicates a fixed number of playback operations, and -1 an unlimited number of playback operations.
239   * The default value is 1.
240   * @type {number}
241   * @syscap SystemCapability.ArkUI.ArkUI.Full
242   * @crossplatform
243   * @atomicservice
244   * @since 11
245   */
246  iterations: number;
247
248  /**
249   * Starting point of animator interpolation.
250   * The default value is 0.
251   * @type {number}
252   * @syscap SystemCapability.ArkUI.ArkUI.Full
253   * @since 6
254   */
255  /**
256   * Starting point of animator interpolation.
257   * The default value is 0.
258   * @type {number}
259   * @syscap SystemCapability.ArkUI.ArkUI.Full
260   * @crossplatform
261   * @since 10
262   */
263  /**
264   * Starting point of animator interpolation.
265   * The default value is 0.
266   * @type {number}
267   * @syscap SystemCapability.ArkUI.ArkUI.Full
268   * @crossplatform
269   * @atomicservice
270   * @since 11
271   */
272  begin: number;
273
274  /**
275   * Ending point of Dynamic Interpolation
276   * The default value is 1.
277   * @type {number}
278   * @syscap SystemCapability.ArkUI.ArkUI.Full
279   * @since 6
280   */
281  /**
282   * Ending point of Dynamic Interpolation
283   * The default value is 1.
284   * @type {number}
285   * @syscap SystemCapability.ArkUI.ArkUI.Full
286   * @crossplatform
287   * @since 10
288   */
289  /**
290   * Ending point of Dynamic Interpolation
291   * The default value is 1.
292   * @type {number}
293   * @syscap SystemCapability.ArkUI.ArkUI.Full
294   * @crossplatform
295   * @atomicservice
296   * @since 11
297   */
298  end: number;
299}
300
301/**
302 * Defines the Animator result interface.
303 * @interface AnimatorResult
304 * @syscap SystemCapability.ArkUI.ArkUI.Full
305 * @since 6
306 */
307/**
308 * Defines the Animator result interface.
309 * @interface AnimatorResult
310 * @syscap SystemCapability.ArkUI.ArkUI.Full
311 * @crossplatform
312 * @since 10
313 */
314/**
315 * Defines the Animator result interface.
316 * @interface AnimatorResult
317 * @syscap SystemCapability.ArkUI.ArkUI.Full
318 * @crossplatform
319 * @atomicservice
320 * @since 11
321 */
322export interface AnimatorResult {
323  /**
324   * Update the options for current animator.
325   * @param { AnimatorOptions } options - Options.
326   * @syscap SystemCapability.ArkUI.ArkUI.Full
327   * @since 6
328   * @deprecated since 9
329   * @useinstead ohos.animator.reset
330   */
331  update(options: AnimatorOptions): void;
332
333  /**
334   * Reset the options for current animator.
335   * @param { AnimatorOptions } options - Options.
336   * @throws { BusinessError } 401 - if the type of the parameter 1 is not object.
337   * @throws { BusinessError } 100001 - if no page is found for pageId or fail to get object property list.
338   * @syscap SystemCapability.ArkUI.ArkUI.Full
339   * @since 9
340   */
341  /**
342   * Reset the options for current animator.
343   * @param { AnimatorOptions } options - Options.
344   * @throws { BusinessError } 401 - if the type of the parameter 1 is not object.
345   * @throws { BusinessError } 100001 - if no page is found for pageId or fail to get object property list.
346   * @syscap SystemCapability.ArkUI.ArkUI.Full
347   * @crossplatform
348   * @since 10
349   */
350  /**
351   * Reset the options for current animator.
352   * @param { AnimatorOptions } options - Options.
353   * @throws { BusinessError } 401 - if the type of the parameter 1 is not object.
354   * @throws { BusinessError } 100001 - if no page is found for pageId or fail to get object property list.
355   * @syscap SystemCapability.ArkUI.ArkUI.Full
356   * @crossplatform
357   * @atomicservice
358   * @since 11
359   */
360  reset(options: AnimatorOptions): void;
361
362  /**
363   * Starts the animation.
364   * @syscap SystemCapability.ArkUI.ArkUI.Full
365   * @since 6
366   */
367  /**
368   * Starts the animation.
369   * @syscap SystemCapability.ArkUI.ArkUI.Full
370   * @crossplatform
371   * @since 10
372   */
373  /**
374   * Starts the animation.
375   * @syscap SystemCapability.ArkUI.ArkUI.Full
376   * @crossplatform
377   * @atomicservice
378   * @since 11
379   */
380  play(): void;
381
382  /**
383   * Ends the animation.
384   * @syscap SystemCapability.ArkUI.ArkUI.Full
385   * @since 6
386   */
387  /**
388   * Ends the animation.
389   * @syscap SystemCapability.ArkUI.ArkUI.Full
390   * @crossplatform
391   * @since 10
392   */
393  /**
394   * Ends the animation.
395   * @syscap SystemCapability.ArkUI.ArkUI.Full
396   * @crossplatform
397   * @atomicservice
398   * @since 11
399   */
400  finish(): void;
401
402  /**
403   * Pauses the animation.
404   * @syscap SystemCapability.ArkUI.ArkUI.Full
405   * @since 6
406   */
407  /**
408   * Pauses the animation.
409   * @syscap SystemCapability.ArkUI.ArkUI.Full
410   * @crossplatform
411   * @since 10
412   */
413  /**
414   * Pauses the animation.
415   * @syscap SystemCapability.ArkUI.ArkUI.Full
416   * @crossplatform
417   * @atomicservice
418   * @since 11
419   */
420  pause(): void;
421
422  /**
423   * Cancels the animation.
424   * @syscap SystemCapability.ArkUI.ArkUI.Full
425   * @since 6
426   */
427  /**
428   * Cancels the animation.
429   * @syscap SystemCapability.ArkUI.ArkUI.Full
430   * @crossplatform
431   * @since 10
432   */
433  /**
434   * Cancels the animation.
435   * @syscap SystemCapability.ArkUI.ArkUI.Full
436   * @crossplatform
437   * @atomicservice
438   * @since 11
439   */
440  cancel(): void;
441
442  /**
443   * Plays the animation in reverse direction.
444   * @syscap SystemCapability.ArkUI.ArkUI.Full
445   * @since 6
446   */
447  /**
448   * Plays the animation in reverse direction.
449   * @syscap SystemCapability.ArkUI.ArkUI.Full
450   * @crossplatform
451   * @since 10
452   */
453  /**
454   * Plays the animation in reverse direction.
455   * @syscap SystemCapability.ArkUI.ArkUI.Full
456   * @crossplatform
457   * @atomicservice
458   * @since 11
459   */
460  reverse(): void;
461
462  /**
463   * Trigger when vsync callback.
464   * @syscap SystemCapability.ArkUI.ArkUI.Full
465   * @since 6
466   */
467  /**
468   * Trigger when vsync callback.
469   * @syscap SystemCapability.ArkUI.ArkUI.Full
470   * @crossplatform
471   * @since 10
472   */
473  /**
474   * Trigger when vsync callback.
475   * @syscap SystemCapability.ArkUI.ArkUI.Full
476   * @crossplatform
477   * @atomicservice
478   * @since 11
479   */
480  onframe: (progress: number) => void;
481
482  /**
483   * The animation is finished.
484   * @syscap SystemCapability.ArkUI.ArkUI.Full
485   * @since 6
486   */
487  /**
488   * The animation is finished.
489   * @syscap SystemCapability.ArkUI.ArkUI.Full
490   * @crossplatform
491   * @since 10
492   */
493  /**
494   * The animation is finished.
495   * @syscap SystemCapability.ArkUI.ArkUI.Full
496   * @crossplatform
497   * @atomicservice
498   * @since 11
499   */
500  onfinish: () => void;
501
502  /**
503   * The animation is canceled.
504   * @syscap SystemCapability.ArkUI.ArkUI.Full
505   * @since 6
506   */
507  /**
508   * The animation is canceled.
509   * @syscap SystemCapability.ArkUI.ArkUI.Full
510   * @crossplatform
511   * @since 10
512   */
513  /**
514   * The animation is canceled.
515   * @syscap SystemCapability.ArkUI.ArkUI.Full
516   * @crossplatform
517   * @atomicservice
518   * @since 11
519   */
520  oncancel: () => void;
521
522  /**
523   * The animation is repeated.
524   * @syscap SystemCapability.ArkUI.ArkUI.Full
525   * @since 6
526   */
527  /**
528   * The animation is repeated.
529   * @syscap SystemCapability.ArkUI.ArkUI.Full
530   * @crossplatform
531   * @since 10
532   */
533  /**
534   * The animation is repeated.
535   * @syscap SystemCapability.ArkUI.ArkUI.Full
536   * @crossplatform
537   * @atomicservice
538   * @since 11
539   */
540  onrepeat: () => void;
541}
542
543/**
544 * Defines the Animator class.
545 * @syscap SystemCapability.ArkUI.ArkUI.Full
546 * @since 6
547 */
548/**
549 * Defines the Animator class.
550 * @syscap SystemCapability.ArkUI.ArkUI.Full
551 * @crossplatform
552 * @since 10
553 */
554/**
555 * Defines the Animator class.
556 * @syscap SystemCapability.ArkUI.ArkUI.Full
557 * @crossplatform
558 * @atomicservice
559 * @since 11
560 */
561export default class Animator {
562  /**
563   * Create an animator object for custom animation.
564   * @param { AnimatorOptions } options - Options.
565   * @returns { AnimatorResult } animator result
566   * @syscap SystemCapability.ArkUI.ArkUI.Full
567   * @since 6
568   * @deprecated since 9
569   * @useinstead ohos.animator.create
570   */
571  static createAnimator(options: AnimatorOptions): AnimatorResult;
572
573  /**
574   * Create an animator object for custom animation.
575   * @param { AnimatorOptions } options - Options.
576   * @returns { AnimatorResult } animator result
577   * @throws { BusinessError } 401 - if parameter error.
578   * @syscap SystemCapability.ArkUI.ArkUI.Full
579   * @since 9
580   */
581  /**
582   * Create an animator object for custom animation.
583   * @param { AnimatorOptions } options - Options.
584   * @returns { AnimatorResult } animator result
585   * @throws { BusinessError } 401 - if parameter error.
586   * @syscap SystemCapability.ArkUI.ArkUI.Full
587   * @crossplatform
588   * @since 10
589   */
590  /**
591   * Create an animator object for custom animation.
592   * @param { AnimatorOptions } options - Options.
593   * @returns { AnimatorResult } animator result
594   * @throws { BusinessError } 401 - if parameter error.
595   * @syscap SystemCapability.ArkUI.ArkUI.Full
596   * @crossplatform
597   * @atomicservice
598   * @since 11
599   */
600  static create(options: AnimatorOptions): AnimatorResult;
601}
602