一、LottieFiles官网
LottieFiles官网是一个面向设计师和开发人员的在线动画文件库,提供了大量的跨平台动画文件,支持在Web,Native,iOS,Android等平台上使用,是目前全球最受欢迎的动画文件库之一。 在LottieFiles官网上可以免费下载数千种使用效果良好的动画文件,并且可以按类别,标签或颜色对其进行排序。此外,用户还可以上传自己制作的动画文件以供其他人使用,并与全球的设计师和开发人员社区互动。 以下是使用LottieFiles官网中的一个动画文件的代码示例:
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.9/lottie.js"></script>
</head>
<body>
<div id="myLottie"></div>
<script>
var animation = lottie.loadAnimation({
container: document.getElementById('myLottie'),
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json'
});
</script>
</body>
</html>
二、LottieFiles安卓版
LottieFiles也提供了安卓版,可以在移动设备上轻松访问LottieFiles的所有资源。安卓版LottieFiles提供了同样的功能,使用户更轻松地筛选、下载和使用动画文件。 此外,LottieFiles安卓版还提供了可视化编辑工具,使用户可以直观地修改动画文件的颜色、大小和动画速度等参数。以下是LottieFiles安卓版的一个编辑界面截图:
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.9/lottie.js"></script>
</head>
<body>
<div id="myLottie"></div>
<script>
var animation = lottie.loadAnimation({
container: document.getElementById('myLottie'),
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json'
});
// 修改动画速度
animation.setSpeed(1.5);
// 修改动画颜色
var shapes = animation.renderer && animation.renderer.elements && animation.renderer.elements[0].elements;
for (var i = 0; i < shapes.length; i++) {
shapes[i].updateColor('#FF0000');
}
// 修改动画大小
var width = window.innerWidth;
var height = window.innerHeight;
var scale = Math.min(width / 400, height / 400);
animation.setParams({
containerWidth: width,
containerHeight: height,
aspectRatio: 1,
hideOnTransparent: false,
rendererSettings: {
scaleMode: 'noScale',
scale: scale
}
});
</script>
</body>
</html>
三、LottieFiles尺寸怎么改
在LottieFiles官网上下载的动画文件原始大小可能并不是用户想要的,因此,LottieFiles也提供了修改动画文件大小的方法。可以轻松地将Lottie文件的高度、宽度和速度等属性进行修改。 以下是修改Lottie文件尺寸的代码示例:
var animation = lottie.loadAnimation({
container: document.getElementById('myLottie'),
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json',
});
// 修改动画速度
animation.setSpeed(1.5);
// 修改动画大小
animation.setSubframe(false);
animation.setSize(width, height);
animation.setQuality('high');
// 设置动画循环或单次播放
animation.setRepeat(2);
animation.setSegment(0, 50);
四、LottieFiles官网怎么进去
要进入LottieFiles官网,只需打开浏览器,输入“https://lottiefiles.com”即可。用户可以免费注册账户,以便上传和下载Lottie文件,并加入全球设计师社区。
五、LottieFiles可以去背景吗
可以。用户可能需要将动画中不需要的部分去掉,例如动画背景。可以使用Adobe After Effects和Bodymovin插件创建动画,然后在Bodymovin的输出设置中选择“Transparent”选项。 以下是在After Effects中设置动画背景透明的方法的代码示例:
var jsonString = '[' +
'{"ty":5,"nm":"Rectangle Copy","d":65,"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[496,452,0],"ix":2},"s":{"a":0,"k":[103,103,100],"ix":6},"d":{"k":[{"n":{"c":[0,0,0,0],"o":1,"t":0,"s":7},"t":24,"s":[17,17,100],"e":[-20,-20,100],"to":[-0.33333334326744,-0.33333334326744,0],"ti":[0,0,0.25]}]},"ao":0,'+
'"sw":19,"sh":19,"sc":"#ffffffff","hd":false,'+
'"ip":0,'+
'"op":210' +
']';
var animationData = JSON.parse(jsonString);
var container = document.getElementById('myLottie');
lottie.loadAnimation({
container: container,
renderer: 'svg',
loop: true,
autoplay: true,
animationData: animationData,
rendererSettings: {
preserveAspectRatio: 'xMidYMid slice',
clearCanvas: true,
context: null,
scaleMode: 'noScale'
},
assetsPath: 'https://cdn.lottiefiles.com/assets_v2/'
});
六、Lottie-web
Lottie-web是LottieFiles官网提供的一项功能,可以轻松地将Lottie文件嵌入到网页中。Lottie-web提供了多个API,可帮助用户轻松地配置和控制动画。 以下是使用Lottie-web的代码示例:
<!DOCTYPE html>
<html>
<head>
<title>Lottie-web示例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.9/lottie.js" type="text/javascript"></script>
</head>
<body>
<div id="lottie"></div>
<script type="text/javascript">
var animation = bodymovin.loadAnimation({
container: document.getElementById('lottie'),
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json'
});
</script>
</body>
</html>
七、Lottie名字寓意
Lottie这个名字的灵感来自于2017年那部广受欢迎的电影《La La Land》,电影中的主角名叫Lottie。LottieFiles官网创始人Hernan Torrisi在看过这部电影后感到非常启发,于是决定为自己的动画库命名为LottieFiles。
八、Lottie动画官网选取
LottieFiles官网拥有丰富的动画文件资源,用户可以按照自己的需求进行筛选和下载。以下是从LottieFiles官网中选取的几个比较热门的动画文件: