如何删除anime.js中的元素?

时间:2017-11-28 20:20:41

标签: javascript animation anime.js

我是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
    })

1 个答案:

答案 0 :(得分:3)

根据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();
    }
});