【问题标题】:how to remove element in anime.js?如何删除anime.js中的元素?
【发布时间】:2017-11-28 20:20:40
【问题描述】:

我是anime.js 的初学者。我制作了一些动画,动画完成后我想删除我正在制作动画的元素。

动画效果很好。我只是无法删除我正在工作的元素,我不想隐藏它

logoTimeline
.add({
        targets: text1,
        duration: 700,
        delay: function(el, index) { return index*50; },
        opacity: 1,

        easing: 'easeOutCirc',
        translateX: function(el, index) {
            return [(-50+index*10),0]
        },
        offset:0
    })
    .add({
        remove:text1
    })

【问题讨论】:

  • 如果您想为问题的详细信息添加一些内容,请使用问题下方的编辑按钮。

标签: javascript animation anime.js


【解决方案1】:

根据API Documentation,您需要添加一个complete 回调函数,该函数将在动画完成后触发:

logoTimeline
.add({
    targets: text1,
    duration: 700,
    delay: function(el, index) { return index*50; },
    opacity: 1,

    easing: 'easeOutCirc',
    translateX: function(el, index) {
        return [(-50+index*10),0]
    },
    offset:0,
    complete: function(anim) {
        logoTimeline.remove();
    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 2011-12-20
    • 2016-07-02
    • 1970-01-01
    • 2021-09-18
    • 1970-01-01
    • 2017-03-03
    相关资源
    最近更新 更多