当前位置:网站首页>最近發現了動畫庫 lottie
最近發現了動畫庫 lottie
2022-07-18 19:57:00 【小白目】
引言:Lottie is a mobile library for Web, and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile! Lottie Docs
作用:
Lottie是一個庫,可以解析使用AE制作的動畫(需要用bodymovin導出為json格式),支持web、ios、android和react native。在web側,lottie-web庫可以解析導出的動畫json文件,並將其以svg或者canvas的方式將動畫繪制到我們頁面中。
優點:
Lottie方法方案是由設計師出動畫,導出為json,給前端播放。所以,使用Lottie方案的好處在於:
- 動畫由設計使用專業的動畫制作工具Adobe After Effects來實現,使動畫實現更加方便,動畫效果也更好;
- 前端可以方便的調用動畫,並對動畫進行控制,减少前端動畫工作量;
- 設計制作動畫,前端展現動畫,專業人做專業事,分工合理;
- 賣家秀即買家秀,還原程度百分之百;
- 使用lottie方案,json文件大小會比gif文件小很多,性能也會更好。
原理:
在Adobe After Effects中,動畫是由一個一個的圖層組成的,在相應的圖層上面添加一些變換(例如:縮放、移動等),這變成為了動畫。 lottie-web提供了很多操控動畫的方法和事件,基本可以滿足對動畫進行控制的需求。
play: 播放動畫
stop: 停止播放動畫
pause: 暫停動畫
goToAndStop: 跳到某一幀動畫,並停止
setDirection: 設置播放方向
setSpeed: 設置播放速度
onComplete: 動畫播放完成觸發
onLoopComplete: 當前循環播放完成觸發
onEnterFrame: 播放一幀動畫的時候觸發
onSegmentStart: 開始播放一個動畫片段的時候觸發使用示例:
<div ref="pokersLottie" />
/**
* 彈窗展示
* @param params.awardImg 獎品圖片
* @param params.popType 彈窗類型
* @param params.labelText 文本
* @param params.goldCount 金幣數量
*/
init(params = {}) {
this.awardImg = params.awardImg;
this.popType = params.popType;
this.labelText = params.labelText;
this.goldCount = params.goldCount;
this.popShow = false;
this.visible = true;
if (params.popType === 'award') {
this.lottieShow = true;
this.lottieLoad({
animationOptions: {
container: this.$refs.pokersLottie,
path: 'https://Activity/poker/data.json',
renderer: 'svg',
autoPlay: true,
loop: false,
},
});
setTimeout(() => {
this.lottieShow = false;
this.popShow = true;
this.$refs.pokersLottie.innerHTML = '';
}, 1500);
}
},
边栏推荐
- 5、 Single table query optimization
- 1.线程与进程
- Dalvik虚拟机和ART
- FIFO signal simulation of internal IP core based on FPGA
- 7.9哈希表(散列表)
- Use of unity dotween plug-in and itween plug-in (notes)
- 【GNN】跨域推荐系统中的图神经网络
- Change signal sampling rate and measurement mean frequency, power and bandwidth
- 【MySql项目实战优化】多行数据转化为同一行多列显示
- 12.快速排序
猜你喜欢

3. Terminate thread

1.线程与进程
![[200 routines OpenCV] 232. Méthode spectrale de caractérisation](/img/54/77f420654cc49723fbdbe845023ec8.png)
[200 routines OpenCV] 232. Méthode spectrale de caractérisation

12. Monotonic stack - solve the problems of rainwater connection and the largest rectangle in the histogram

射频芯片ATE测试从入门到放弃之收发机

Horizon 8 测试环境部署(5): UAG 部署及负载均衡配置-1

5.线程分离

安利一款笔记工具---Obsidian

Company equity distribution reference

Interview micro service
随机推荐
Unity typewriter effect timer implementation and dotween implementation (notes)
Machine code
Horizon 8 test environment deployment (6): UAG load balancing configuration-2
对话印奇:我们所坚持的不会改变,旷视跳出企业科研“周期律”
Zkapp transaction snark in Mina
Film knowledge atlas and the construction of a template based question and answer system
树莓派初体验
vivado之COE文件使用方法
Share constantly, tread the waves | developers say · dtalk mid year appreciation
SI24R2E_ Smart electronic student card 2.4GHz attendance scheme chip
[200 opencv routines] 232 Spectral method of feature description
Raspberry pie shutdown restart command
2.Markdown使用说明
安利一款笔记工具---Obsidian
The 20th anniversary of Beijing Hyundai: Streamline product layout and strive to achieve 520000 vehicles by 2025
Singleton mode in QT: implement a singleton interface class
8. Island issue
绿色安装MySQL5.7版本----配置my.ini文件注意事项
安卓 Day 26 :数据库Two
全员满分!中国队IMO达成四连冠,大比分领先第二名韩国