Search code examples
javascriptjquerybodymovin

how to check if bodymovin animation is complete?


I want the to destroy the animation when is complete animating. tried addEventListener that didn't work.

anim = bodymovin.loadAnimation(params);
animContainer.addEventListener("complete", myScript);

function myScript(){
      anim.destroy();
}

Solution

  • One way to go would be to listen for native 'transitionend' event on the element that is being animated.

    element.addEventListener("transitionend", anim.destroy());