示例
Lottie是Airbnb开发的一种轻量级的JavaScript库,它能够在Web、iOS和Android平台上呈现高质量、动态的矢量动画。Lottie使得在应用中使用复杂的矢量动画变得更加容易,并且在不同平台上能够实现更高的视觉一致性。而lottie-web是Lottie的Web版本,使用它可以在Web页面中展示高品质、流畅的动态矢量动画。
与css动画、gif、帧动画的比较
安装
npm i lottie-web
Vue中使用
创建LottieAni文件
<template> <div ref="lottieBox"></div></template><script setup> import lottie from "lottie-web"; import { onMounted, ref, defineProps } from "vue"; const props = defineProps({ src: { type: Object, default: ()=>{}, }, path: { type: String, default: "", }, loop: { type: Boolean, default: true, }, autoplay: { type: Boolean, default: true, }, }); const lottieBox = ref(null); onMounted(() => { if (lottieBox.value) { const animation = lottie.loadAnimation({ container: lottieBox.value, renderer: "svg", // 渲染方式:svg:支持交互、不会失帧、canvas、html:支持3D,支持交互 loop: props.loop, // 循环播放,默认:true autoplay: props.autoplay, // 自动播放 ,默认true path: props.path,//网络路径 animationData: Object.keys(props.src).length == 0 ? "" : props.src,//本地路径,优先级更高 AE动画使用bodymovie导出为json数据 }); } });</script>
API文档
基本用法
创建const animation = lottie.loadAnimation({ container: document.getElementById('domId'), // 绑定dom节点 renderer: 'svg', // 渲染方式:svg、canvas loop: true, // 是否循环播放,默认:false autoplay: true, // 是否自动播放, 默认true animationData: // AE动画使用bodymovie导出为json数据})常用方法animation.play(); // 播放,从当前帧开始播放animation.stop(); // 停止,并回到第0帧animation.pause(); // 暂停,并保持当前帧animation.goToAndStop(value, isFrame); // 跳到某个时刻/帧并停止isFrame(默认false)指示value表示帧还是时间(毫秒)animation.goToAndPlay(value, isFrame); // 跳到某个时刻/帧并进行播放animation.goToAndStop(30, true); // 跳转到第30帧并停止animation.goToAndPlay(300); // 跳转到第300毫秒并播放animation.playSegments(arr, forceFlag); // arr可以包含两个数字或者两个数字组成的数组,forceFlag表示是否立即强制播放该片段animation.playSegments([10,20], false); // 播放完之前的片段,播放10-20帧animation.playSegments([[0,5],[10,18]], true); // 直接播放0-5帧和10-18帧animation.setSpeed(speed); // 设置播放速度,speed为1表示正常速度animation.setDirection(direction); // 设置播放方向,1表示正向播放,-1表示反向播放animation.destroy(); // 删除该动画,移除相应的元素标签等。常用的事件animation.addEventListener('data_ready', () => {}) // 动画数据加载完毕animation.addEventListener('config_ready', () => {}) // 完成初始配置后animation.addEventListener('data_failed', () => {}) // 加载动画数据失败animation.addEventListener('loaded_images', () => {}) // 所有图片加载成功或者失败animation.addEventListener('DOMLoaded', () => {}) // 将元素添加到DOM后
Lottie-web 提供了丰富的 API,以便我们控制动画的播放、暂停、重置、改变速度等操作。下面列出一些常用的 API:
lottie.loadAnimation
:加载动画文件并返回一个动画实例。animation.play
: 播放动画。animation.stop
: 停止动画。animation.setSpeed
:设置动画的播放速度。animation.setDirection
:设置动画的播放方向。animation.goToAndStop
:跳转到指定时间点或帧,并暂停。animation.destroy
:销毁动画实例。
options
参数包含以下属性:
参数 类型 默认值 说明 animationData object or array null Lottie动画数据 path string null Lottie动画的JSON文件路径 renderer string 'svg' Lottie动画渲染方式,支持'canvas'和'svg' loop bool or number true 是否循环播放动画 autoplay bool false 是否自动播放动画 name string null Lottie动画的名称 assetsPath string null Lottie动画资源文件夹的路径 rendererSettings object {} Lottie动画渲染的一些配置 在
options
参数中,animationData
和path
必须设置其中之一。animationData
可以直接传入Lottie动画数据,而path
则是Lottie动画的JSON文件路径,可以通过require或import语句导入
Lottie的免费资源
LottieFiles: Download Free lightweight animations for website & apps.
Lottie的动画是通过AE制作好了动画后,再使用bodymovie导出为json格式
JSON动画配置文件
ammNoticeData.json
{"v":"5.6.1","fr":25,"ip":0,"op":150,"w":896,"h":480,"nm":"插图整","ddd":0,"assets":[{"id":"image_0","w":132,"h":58,"u":"","p":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAAA6CAYAAABxhPGiAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikG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lSQMw4t4FEWLeqPIsuxuCGutArho6jzPFafh9tgseA01dg9nf09AGGPMXKYWa7PZoK7rbzEiAjPTFMR2u92uBhEEAbquu4gzM8YgRESYmVeDGNMURLTbrfq8mdQYxGbNUtwCQUQUhmG46onatsXT09NiiNUBAMA5B6LL4WitHYR4SEPWdY2hi+u67mcgxgD8tn8K4ZyDc85NDavVlOc5ROQi3k/Q+kcgPj4+MHTLv7+/A8Cfh0OUZQlmxlCJy7IEgHIIwjnnVoPIsgxRFF3E27ZFXdftGETbtu0qAG3b4u3tbaoU5dixu6/L9HtkjNEoikbXFwBGpyIT0d0Afmk/tEBO03R2RQUATVVVd0Hs93s9HA6D2/oszDqxV2PMzQBFUSgzDxqlPgvVHAAACBFd5ba8fBmGvOoX98VLIACguDYb1loNw1DHfMp+v1ecXhssFgdBYJc6rzmA3nEtKsO54iUetKoqZeY5gAZXlOFchpl1yARVVaXGGCUifXl5eRiAFwPIiEhFREVEmVmJSJMkGWxg78ZxmgeTAL+uhCGcptwGp1dGwswkIp+jues65HmOsiwdgGcAr3N/ei3EkML+4x8QHYAcE8+Fc/0FO1Qn1fLp8BwAAAAASUVORK5CYII=","e":0}],"layers":[{"ddd":0,"ind":1,"ty":2,"nm":"50%.png","cl":"png","refId":"image_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[412,29,0],"ix":2},"a":{"a":0,"k":[66,29,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":38,"s":[80,80,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":43,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":48,"s":[80,80,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":53,"s":[100,100,100]},{"t":58,"s":[80,80,100]}],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":2,"nm":"黑 3","refId":"image_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":79.577,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":89.639,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":139.939,"s":[100]},{"t":150,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":79.577,"s":[729,151,0],"to":[-2.167,-19.5,0],"ti":[22.595,7.636,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":89.639,"s":[716,34,0],"to":[-36.235,-12.245,0],"ti":[6.194,-0.817,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":139.939,"s":[139,28,0],"to":[-9.763,1.287,0],"ti":[0.167,-31.167,0]},{"t":150,"s":[138,215,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[80,80,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":2,"nm":"白 2","refId":"image_2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":60.498,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":70.559,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":120.859,"s":[100]},{"t":130.9208984375,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":60.498,"s":[729,151,0],"to":[-2.167,-19.5,0],"ti":[22.595,7.636,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":70.559,"s":[716,34,0],"to":[-36.235,-12.245,0],"ti":[6.194,-0.817,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":120.859,"s":[139,28,0],"to":[-9.763,1.287,0],"ti":[0.167,-31.167,0]},{"t":130.9208984375,"s":[138,215,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[80,80,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":2,"nm":"黑 2","refId":"image_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":35,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":45.061,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":95.361,"s":[100]},{"t":105.4228515625,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":35,"s":[729,151,0],"to":[-2.167,-19.5,0],"ti":[22.595,7.636,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":45.061,"s":[716,34,0],"to":[-36.235,-12.245,0],"ti":[6.194,-0.817,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":95.361,"s":[139,28,0],"to":[-9.763,1.287,0],"ti":[0.167,-31.167,0]},{"t":105.4228515625,"s":[138,215,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[80,80,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":9,"ty":2,"nm":"白","refId":"image_2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":36.385,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":52.923,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":69.462,"s":[100]},{"t":86,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":36.385,"s":[260,328,0],"to":[18,0,0],"ti":[-37.667,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":52.923,"s":[368,328,0],"to":[37.667,0,0],"ti":[-33.167,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":69.462,"s":[486,328,0],"to":[33.167,0,0],"ti":[-13.5,0,0]},{"t":86,"s":[567,328,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":10,"ty":2,"nm":"黑","refId":"image_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":16.538,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":33.078,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":49.615,"s":[100]},{"t":66.154296875,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":16.538,"s":[260,328,0],"to":[18,0,0],"ti":[-37.667,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":33.078,"s":[368,328,0],"to":[37.667,0,0],"ti":[-33.167,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":49.615,"s":[486,328,0],"to":[33.167,0,0],"ti":[-13.5,0,0]},{"t":66.154296875,"s":[567,328,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":11,"ty":2,"nm":"白","refId":"image_2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":16.538,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":33.078,"s":[100]},{"t":49.615234375,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[260,328,0],"to":[18,0,0],"ti":[-37.667,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":16.538,"s":[368,328,0],"to":[37.667,0,0],"ti":[-33.167,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":33.078,"s":[486,328,0],"to":[33.167,0,0],"ti":[-13.5,0,0]},{"t":49.615234375,"s":[567,328,0]}],"ix":2},"a":{"a":0,"k":[16.5,20,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":150,"st":0,"bm":0}],"markers":[]}
使用
<template> <LottieAni :src="ammNoticeData" /></template><script setup> import { ref, reactive, onMounted, computed } from 'vue'; import ammNoticeData from "@/assets/json/ammNoticeData.json"; import LottieAni from "@/components/LottieAni";</script><style lang="less" scoped></style>