UNPKG

2.86 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps } from './common'
3interface LottieProps extends StandardProps {
4 /** 是否自动播放。
5 * @supported alipay
6 * @default false
7 */
8 autoplay?: boolean
9
10 /** Lottie 资源地址。包含近端(包内地址)和远端(网络)的 JSON 文件地址。
11 * 与 djangoId 二选一。
12 * @supported alipay
13 */
14 path?: string
15
16 /** 播放速度。正数为正向播放,负数负向播放。
17 * @supported alipay
18 * @default 1.0
19 */
20 speed?: number
21
22 /** 循环次数。
23 *
24 * 如果是负数表示无限次。
25 * 如果是 0 表示不循环,播放一次。
26 * 如果是 1 表示循环一次,播放两次。
27 * @supported alipay
28 * @default 0
29 */
30 repeatCount?: number
31
32 /** 是否自动回播。
33 * @supported alipay
34 * @default false
35 */
36 autoReverse?: boolean
37
38 /** 资源地址。"/" 表明是小程序根目录。
39 * @supported alipay
40 */
41 assetsPath?: string
42
43 /** 兜底图或者降级图地址。
44 *
45 * 1. 支持本地资源,案例:'/image/lottie/lottie2_default.png'。
46 * 支持 http 的 cdn 地址、近端地址。
47 * 小程序场景不支持 djangoId。
48 * @supported alipay
49 */
50 placeholder?: string
51
52 /** 在线资源的 md5 校验。
53 * djangoId=https://b.zip。
54 * 可以使用 b.zip 加密 获取 md5 值
55 * md5="77c6c86fc89ba94cc0a9271b77ae77d2"
56 * @supported alipay
57 */
58 md5?: string
59
60 /** 降级。降级是指如遇低端设备,Lottie 会降级展示为 placeholder。
61 * 当 optimize 为 true ,并且传入了 placeholder 时,在低端设备上只会展示 placeholder,不展示 Lottie。
62 * 低端设备如下所示:
63 *
64 * iOS :小于等于 iPhone6P
65 * Android:内存容量小于 3G
66 * @supported alipay
67 * @default false
68 */
69 optimize?: boolean
70
71 /** 当数据下载+视图创建完成时触发。
72 * @supported alipay
73 */
74 onDataReady?: CommonEventFunction
75
76 /** 数据加载失败时触发。
77 * @supported alipay
78 */
79 onDataFailed?: CommonEventFunction
80
81 /** 动画开始时触发。
82 * @supported alipay
83 */
84 onAnimationStart?: CommonEventFunction
85
86 /** 动画结束时触发。
87 * @supported alipay
88 */
89 onAnimationEnd?: CommonEventFunction
90
91 /** 动画一次重播结束。
92 * @supported alipay
93 */
94 onAnimationRepeat?: CommonEventFunction
95
96 /** 动画取消。业务调用 Cancel 时回调。
97 * @supported alipay
98 */
99 onAnimationCancel?: CommonEventFunction
100
101 /** 参数化时,数据准备完成,等待业务传入参数化值。
102 * @supported alipay
103 */
104 onDataLoadReady?: CommonEventFunction
105}
106
107/** Lottie
108 * @classification media
109 * @supported alipay
110 * @see https://opendocs.alipay.com/mini/component/lottie
111 */
112declare const Lottie: ComponentType<LottieProps>
113export { Lottie, LottieProps }