• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 * Customize spring properties.
23 *
24 * @syscap SystemCapability.ArkUI.ArkUI.Full
25 * @systemapi
26 * @since 7
27 */
28declare class SpringProp {
29  /**
30   * Constructor parameters
31   *
32   * @param { number } mass
33   * @param { number } stiffness
34   * @param { number } damping
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @systemapi
37   * @since 7
38   */
39  constructor(mass: number, stiffness: number, damping: number);
40}
41
42/**
43 * Spring animation model. You can build a spring animation based on the start point, end point, initial speed, and spring attributes.
44 *
45 * @syscap SystemCapability.ArkUI.ArkUI.Full
46 * @systemapi
47 * @since 7
48 */
49declare class SpringMotion {
50  /**
51   * Constructor parameters
52   *
53   * @param { number } start
54   * @param { number } end
55   * @param { number } velocity
56   * @param { SpringProp } prop
57   * @syscap SystemCapability.ArkUI.ArkUI.Full
58   * @systemapi
59   * @since 7
60   */
61  constructor(start: number, end: number, velocity: number, prop: SpringProp);
62}
63
64/**
65 * Friction animation model. You can build friction animation by friction force, initial position, and initial velocity.
66 *
67 * @syscap SystemCapability.ArkUI.ArkUI.Full
68 * @systemapi
69 * @since 7
70 */
71declare class FrictionMotion {
72  /**
73   * Constructor parameters
74   *
75   * @param { number } friction
76   * @param { number } position
77   * @param { number } velocity
78   * @syscap SystemCapability.ArkUI.ArkUI.Full
79   * @systemapi
80   * @since 7
81   */
82  constructor(friction: number, position: number, velocity: number);
83}
84
85/**
86 * Rolling animation model: You can build rolling animation based on the initial position, initial speed, boundary position, and spring attributes.
87 *
88 * @syscap SystemCapability.ArkUI.ArkUI.Full
89 * @systemapi
90 * @since 7
91 */
92declare class ScrollMotion {
93  /**
94   * Constructor parameters
95   *
96   * @param { number } position
97   * @param { number } velocity
98   * @param { number } min
99   * @param { number } max
100   * @param { SpringProp } prop
101   * @syscap SystemCapability.ArkUI.ArkUI.Full
102   * @systemapi
103   * @since 7
104   */
105  constructor(position: number, velocity: number, min: number, max: number, prop: SpringProp);
106}
107
108/**
109 * Defines Animator.
110 *
111 * @interface AnimatorInterface
112 * @syscap SystemCapability.ArkUI.ArkUI.Full
113 * @systemapi
114 * @since 7
115 */
116interface AnimatorInterface {
117  /**
118   * Constructor parameters
119   *
120   * @param { string } value
121   * @returns { AnimatorAttribute }
122   * @syscap SystemCapability.ArkUI.ArkUI.Full
123   * @systemapi
124   * @since 7
125   */
126  (value: string): AnimatorAttribute;
127}
128
129/**
130 * Defines AnimatorAttribute.
131 *
132 * @extends CommonMethod<AnimatorAttribute>
133 * @syscap SystemCapability.ArkUI.ArkUI.Full
134 * @systemapi
135 * @since 7
136 */
137declare class AnimatorAttribute extends CommonMethod<AnimatorAttribute> {
138  /**
139   * Controls the playback status. The default value is the initial state.
140   *
141   * @param { AnimationStatus } value
142   * @returns { AnimatorAttribute }
143   * @syscap SystemCapability.ArkUI.ArkUI.Full
144   * @systemapi
145   * @since 7
146   */
147  state(value: AnimationStatus): AnimatorAttribute;
148
149  /**
150   * Animation duration, in milliseconds.
151   *
152   * @param { number } value
153   * @returns { AnimatorAttribute }
154   * @syscap SystemCapability.ArkUI.ArkUI.Full
155   * @systemapi
156   * @since 7
157   */
158  duration(value: number): AnimatorAttribute;
159
160  /**
161   * Animation curve, default to linear curve
162   *
163   * @param { Curve } value
164   * @returns { AnimatorAttribute }
165   * @syscap SystemCapability.ArkUI.ArkUI.Full
166   * @systemapi
167   * @since 7
168   */
169  curve(value: Curve): AnimatorAttribute;
170
171  /**
172   * Delayed animation playback duration, in milliseconds. By default, the animation is not delayed.
173   *
174   * @param { number } value
175   * @returns { AnimatorAttribute }
176   * @syscap SystemCapability.ArkUI.ArkUI.Full
177   * @systemapi
178   * @since 7
179   */
180  delay(value: number): AnimatorAttribute;
181
182  /**
183   * Sets the state before and after the animation starts.
184   *
185   * @param { FillMode } value
186   * @returns { AnimatorAttribute }
187   * @syscap SystemCapability.ArkUI.ArkUI.Full
188   * @systemapi
189   * @since 7
190   */
191  fillMode(value: FillMode): AnimatorAttribute;
192
193  /**
194   * The default playback is once. If the value is -1, the playback is unlimited.
195   *
196   * @param { number } value
197   * @returns { AnimatorAttribute }
198   * @syscap SystemCapability.ArkUI.ArkUI.Full
199   * @systemapi
200   * @since 7
201   */
202  iterations(value: number): AnimatorAttribute;
203
204  /**
205   * Sets the animation playback mode. By default, the animation starts to play again after the playback is complete.
206   *
207   * @param { PlayMode } value
208   * @returns { AnimatorAttribute }
209   * @syscap SystemCapability.ArkUI.ArkUI.Full
210   * @systemapi
211   * @since 7
212   */
213  playMode(value: PlayMode): AnimatorAttribute;
214
215  /**
216   * Configure the physical animation algorithm.
217   *
218   * @param { SpringMotion | FrictionMotion | ScrollMotion } value
219   * @returns { AnimatorAttribute }
220   * @syscap SystemCapability.ArkUI.ArkUI.Full
221   * @systemapi
222   * @since 7
223   */
224  motion(value: SpringMotion | FrictionMotion | ScrollMotion): AnimatorAttribute;
225
226  /**
227   * Status callback, which is triggered when the animation starts to play.
228   *
229   * @param { function } event
230   * @returns { AnimatorAttribute }
231   * @syscap SystemCapability.ArkUI.ArkUI.Full
232   * @systemapi
233   * @since 7
234   */
235  onStart(event: () => void): AnimatorAttribute;
236
237  /**
238   * Status callback, triggered when the animation pauses.
239   *
240   * @param { function } event
241   * @returns { AnimatorAttribute }
242   * @syscap SystemCapability.ArkUI.ArkUI.Full
243   * @systemapi
244   * @since 7
245   */
246  onPause(event: () => void): AnimatorAttribute;
247
248  /**
249   * Status callback, triggered when the animation is replayed.
250   *
251   * @param { function } event
252   * @returns { AnimatorAttribute }
253   * @syscap SystemCapability.ArkUI.ArkUI.Full
254   * @systemapi
255   * @since 7
256   */
257  onRepeat(event: () => void): AnimatorAttribute;
258
259  /**
260   * Status callback, which is triggered when the animation is canceled.
261   *
262   * @param { function } event
263   * @returns { AnimatorAttribute }
264   * @syscap SystemCapability.ArkUI.ArkUI.Full
265   * @systemapi
266   * @since 7
267   */
268  onCancel(event: () => void): AnimatorAttribute;
269
270  /**
271   * Status callback, which is triggered when the animation playback is complete.
272   *
273   * @param { function } event
274   * @returns { AnimatorAttribute }
275   * @syscap SystemCapability.ArkUI.ArkUI.Full
276   * @systemapi
277   * @since 7
278   */
279  onFinish(event: () => void): AnimatorAttribute;
280
281  /**
282   * The callback input parameter is the interpolation during animation playback.
283   *
284   * @param { function } event
285   * @returns { AnimatorAttribute }
286   * @syscap SystemCapability.ArkUI.ArkUI.Full
287   * @systemapi
288   * @since 7
289   */
290  onFrame(event: (value: number) => void): AnimatorAttribute;
291}
292
293/**
294 * Defines Animator Component.
295 *
296 * @syscap SystemCapability.ArkUI.ArkUI.Full
297 * @systemapi
298 * @since 7
299 */
300declare const Animator: AnimatorInterface;
301
302/**
303 * Defines Animator Component instance.
304 *
305 * @syscap SystemCapability.ArkUI.ArkUI.Full
306 * @systemapi
307 * @since 9
308 */
309declare const AnimatorInstance: AnimatorAttribute;
310