lottie切换动画

当lottie动画需要切换动画时,就是在第一个动画结束之后,播放第二个动画,看了一下lottie的github上的readme,找到一个onComplete方法,现在直接贴代码

var baseParam={
        container: document.getElementById('lottie'),
        renderer: 'svg',
        autoplay: true,
    }
    var firstParam=JSON.parse(JSON.stringify(baseParam))
    firstParam.loop=false;
    firstParam.animationData=json;
    anim=lottie.loadAnimation(firstParam);
    anim.onComplete = () => {
        console.log("onComplete..."); //eslint-disable-line
        anim.destroy()
        var secondParam=JSON.parse(JSON.stringify(baseParam))
        secondParam.loop=false;
        secondParam.animationData=defaultAnimation
        lottie.loadAnimation(secondParam);
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容