I am attempting to fire an event on a web component when a CSS animation has completed, however there is a possibility the user might clear the animation from the element using animation: none; meaning the transitionend event never fires:
// wait for dialog close animation to end before firing closed event
element.addEventListener('transitionend', function() {
// fire dialog closed event
self.dispatchEvent(new CustomEvent('pure-dialog-closed', {
bubbles: true,
cancelable: true
}));
});
To ensure my custom event always fires, I need to determine if the element or any of its children have an animation applied and if not, fire the pure-dialog-closed event immediately.
I have tried checking style.animationName and self.style.transition but it does not appear to be working. I need a simple way of checking if an element, or any of its children have a CSS animation applied.