1

Is there a way to remove an animation? When I run document.getAnimations(), I see a list of my animations but I want to remove some after they they are completed. Is there a way to do this? I checked the Web Animation API but didn't see it in the documentation.

MauirceA
  • 291
  • 1
  • 13
  • Does this answer your question? [What is the cleanest way to disable CSS transition effects temporarily?](https://stackoverflow.com/questions/11131875/what-is-the-cleanest-way-to-disable-css-transition-effects-temporarily) – Don't Panic Dec 30 '20 at 09:55
  • 1
    Can you clarify what `remove` means, exactly, as opposed to `just stopping`? If you mean remove the animation, how is that different from stopping the animation? If you want to remove the entire elements, [there is an example in the MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations#Examples). – Don't Panic Dec 30 '20 at 09:58
  • thanks @Don'tPanic. I meant to remove just the animation from the array that `getAnimations()` returns. I think removing the element is the only way to remove the Animation that is attached to it. – MauirceA Dec 30 '20 at 11:01

1 Answers1

0

You could listen for the animationEnd event on an element and then set el.style.animation = 'none'.

A Haworth
  • 30,908
  • 4
  • 11
  • 14