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 * Defines the ImageAnimator Interface. 18 * @since 7 19 */ 20interface ImageAnimatorInterface { 21 /** 22 * ImageAnimator is returned. 23 * @since 7 24 */ 25 (): ImageAnimatorAttribute; 26} 27 28/** 29 * Defines the ImageFrameInfo Interface. 30 * @since 7 31 */ 32interface ImageFrameInfo { 33 /** 34 * Image path 35 * @type { string } 36 * @since 7 37 */ 38 /** 39 * Image path 40 * @type { string | Resource } 41 * @since 9 42 */ 43 src: string | Resource; 44 /** 45 * Image width 46 * @type: { number | string } 47 * @since 7 48 */ 49 width?: number | string; 50 /** 51 * Image height 52 * @type: { number | string } 53 * @since 7 54 */ 55 height?: number | string; 56 /** 57 * Vertical coordinate of the image relative to the upper left corner of the component 58 * @type: { number | string } 59 * @since 7 60 */ 61 top?: number | string; 62 /** 63 * Horizontal coordinate of the image relative to the upper left corner of the component 64 * @type: { number | string } 65 * @since 7 66 */ 67 left?: number | string; 68 /** 69 * Playback duration of this image frame, in milliseconds. 70 * @type: { number } 71 * @since 7 72 */ 73 duration?: number; 74} 75 76/** 77 * inheritance CommonMethod 78 * @since 7 79 */ 80declare class ImageAnimatorAttribute extends CommonMethod<ImageAnimatorAttribute> { 81 /** 82 * list images 83 * @since 7 84 */ 85 images(value: Array<ImageFrameInfo>): ImageAnimatorAttribute; 86 87 /** 88 * The default value is the initial state, which is used to control the playback status. 89 * @since 7 90 */ 91 state(value: AnimationStatus): ImageAnimatorAttribute; 92 93 /** 94 * The unit is millisecond. 95 * @since 7 96 */ 97 duration(value: number): ImageAnimatorAttribute; 98 99 /** 100 * Set the playback sequence. 101 * @since 7 102 */ 103 reverse(value: boolean): ImageAnimatorAttribute; 104 105 /** 106 * Sets whether the image size is fixed to the component size. 107 * @since 7 108 */ 109 fixedSize(value: boolean): ImageAnimatorAttribute; 110 111 /** 112 * Indicates whether to enable pre-decoding. 113 * @since 7 114 * @deprecated since 9 115 */ 116 preDecode(value: number): ImageAnimatorAttribute; 117 118 /** 119 * Sets the state before and after the animation starts 120 * @since 7 121 */ 122 fillMode(value: FillMode): ImageAnimatorAttribute; 123 124 /** 125 * Played once by default 126 * @since 7 127 */ 128 iterations(value: number): ImageAnimatorAttribute; 129 130 /** 131 * Status callback, which is triggered when the animation starts to play. 132 * @since 7 133 */ 134 onStart(event: () => void): ImageAnimatorAttribute; 135 136 /** 137 * Status callback, which is triggered when the animation pauses. 138 * @since 7 139 */ 140 onPause(event: () => void): ImageAnimatorAttribute; 141 142 /** 143 * Status callback, triggered when the animation is replayed 144 * @since 7 145 */ 146 onRepeat(event: () => void): ImageAnimatorAttribute; 147 148 /** 149 * Status callback, which is triggered when the animation is canceled. 150 * @since 7 151 */ 152 onCancel(event: () => void): ImageAnimatorAttribute; 153 154 /** 155 * Status callback, which is triggered when the animation playback is complete. 156 * @since 7 157 */ 158 onFinish(event: () => void): ImageAnimatorAttribute; 159} 160 161/** 162 * Defines ImageAnimator Component. 163 * @since 7 164 */ 165declare const ImageAnimator: ImageAnimatorInterface; 166 167/** 168 * Defines ImageAnimator Component instance. 169 * @since 7 170 */ 171declare const ImageAnimatorInstance: ImageAnimatorAttribute; 172