@eva/plugin-renderer-lottie 2.0.1-beta.3 → 2.0.1-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.renderer.lottie.js +311 -177
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +464 -196
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +80 -0
- package/dist/plugin-renderer-lottie.esm.js +469 -201
- package/package.json +3 -3
|
@@ -22,31 +22,104 @@ declare interface IExpandOpts {
|
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
24
|
}>;
|
|
25
|
+
direction?: 1 | -1;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
declare interface IOptions {
|
|
28
29
|
resource: string;
|
|
29
30
|
width?: number;
|
|
30
31
|
height?: number;
|
|
32
|
+
replaceData?: boolean;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Lottie 动画组件
|
|
37
|
+
*
|
|
38
|
+
* Lottie 组件用于播放 Adobe After Effects 导出的 Lottie 动画文件。
|
|
39
|
+
* Lottie 是一种基于 JSON 的动画格式,可以实现复杂的矢量动画效果,
|
|
40
|
+
* 文件体积小、性能高,适用于图标动画、loading 动画、复杂 UI 动效等场景。
|
|
41
|
+
*
|
|
42
|
+
* 主要功能:
|
|
43
|
+
* - 播放 Lottie JSON 动画
|
|
44
|
+
* - 支持动画片段播放和循环
|
|
45
|
+
* - 支持插槽(slot)动态替换内容
|
|
46
|
+
* - 支持帧事件监听
|
|
47
|
+
* - 支持交互热区绑定
|
|
48
|
+
* - 支持动态替换动画数据
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // 基础用法
|
|
53
|
+
* const animation = new GameObject('animation');
|
|
54
|
+
* animation.addComponent(new Lottie({
|
|
55
|
+
* resource: 'loadingAnimation', // Lottie JSON 资源
|
|
56
|
+
* autoStart: true
|
|
57
|
+
* }));
|
|
58
|
+
*
|
|
59
|
+
* // 播放指定片段
|
|
60
|
+
* const lottie = animation.getComponent('Lottie');
|
|
61
|
+
* lottie.play([0, 60], { repeats: -1 }); // 播放 0-60 帧,无限循环
|
|
62
|
+
*
|
|
63
|
+
* // 动态替换插槽内容
|
|
64
|
+
* lottie.play([0, 120], {
|
|
65
|
+
* slot: [{
|
|
66
|
+
* name: 'avatar',
|
|
67
|
+
* type: 'IMAGE',
|
|
68
|
+
* value: 'user-avatar.png',
|
|
69
|
+
* style: { width: 100, height: 100 }
|
|
70
|
+
* }, {
|
|
71
|
+
* name: 'username',
|
|
72
|
+
* type: 'TEXT',
|
|
73
|
+
* value: '玩家名称',
|
|
74
|
+
* style: { fontSize: 24 }
|
|
75
|
+
* }]
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // 监听特定帧事件
|
|
79
|
+
* lottie.on('@30', () => {
|
|
80
|
+
* console.log('到达第 30 帧');
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // 绑定点击热区
|
|
84
|
+
* lottie.onTap('buttonLayer', () => {
|
|
85
|
+
* console.log('按钮被点击');
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
33
89
|
export declare class Lottie extends Component {
|
|
90
|
+
/** 插槽配置 */
|
|
34
91
|
slot: {
|
|
35
92
|
[key: string]: string;
|
|
36
93
|
};
|
|
94
|
+
/** 待替换的数据 */
|
|
95
|
+
_replaceData: Record<string, string> | null;
|
|
96
|
+
/** 组件名称 */
|
|
37
97
|
static componentName: string;
|
|
98
|
+
/** Lottie 动画实例 */
|
|
38
99
|
anim: any;
|
|
100
|
+
/** Lottie 配置选项 */
|
|
39
101
|
options: ExtendOptions;
|
|
102
|
+
/** 资源加载状态 */
|
|
40
103
|
loadStatus: boolean;
|
|
104
|
+
/** 首次播放回调 */
|
|
41
105
|
firstPlay: () => void | null;
|
|
106
|
+
/** 前一次的插槽内容 */
|
|
42
107
|
prevSlot: {
|
|
43
108
|
[name: string]: any;
|
|
44
109
|
};
|
|
110
|
+
/** 当前的插槽内容 */
|
|
45
111
|
currentSlot: {
|
|
46
112
|
[name: string]: any;
|
|
47
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* 构造 Lottie 组件
|
|
116
|
+
* @param options - Lottie 配置选项
|
|
117
|
+
* @param options.resource - Lottie JSON 资源名称
|
|
118
|
+
* @param options.autoStart - 是否自动开始播放
|
|
119
|
+
*/
|
|
48
120
|
constructor(options: IOptions);
|
|
49
121
|
play(params?: number[], expandOpts?: IExpandOpts): void;
|
|
122
|
+
replaceData(data: Record<string, string>): void;
|
|
50
123
|
playParamsHandle(params: any): any[];
|
|
51
124
|
onTap(name: any, callback: any): void;
|
|
52
125
|
}
|
|
@@ -59,9 +132,16 @@ export declare class LottieSystem extends Renderer {
|
|
|
59
132
|
rendererManager: RendererManager;
|
|
60
133
|
containerManager: ContainerManager;
|
|
61
134
|
managerLife: string[];
|
|
135
|
+
/**
|
|
136
|
+
* System 初始化用,可以配置参数,游戏未开始
|
|
137
|
+
*
|
|
138
|
+
* System init, set params, game is not begain
|
|
139
|
+
* @param param init params
|
|
140
|
+
*/
|
|
62
141
|
init(): void;
|
|
63
142
|
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
64
143
|
add(changed: ComponentChanged): Promise<void>;
|
|
144
|
+
getDir(url: string): string;
|
|
65
145
|
remove(changed: ComponentChanged): void;
|
|
66
146
|
}
|
|
67
147
|
|