0

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();
}
Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104
Siyanda Cele
  • 35
  • 1
  • 8

3 Answers3

3
  anim = bodymovin.loadAnimation(animData);
  anim.addEventListener("complete", function() {
    anim.destroy();
  });
Jon Lambson
  • 510
  • 2
  • 11
1

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

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

The following coded work...

  anim.addEventListener("complete", function(){
      anim.destroy());
  });
Siyanda Cele
  • 35
  • 1
  • 8