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