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