A utility method that returns a promise which is resolved the next time that the "animationend" or "transitionend" event is emitted from the provided target element. This makes it easy to string together multiple animations in sequence:
target
async function closeModal() { dialogElement.classList.add('collapse'); await waitForAnimationEnd(dialogElement); dialogElement.classList.remove('collapse'); dialogElement.classList.add('fade-out'); await waitForAnimationEnd(dialogElement); modalClosed();} Copy
async function closeModal() { dialogElement.classList.add('collapse'); await waitForAnimationEnd(dialogElement); dialogElement.classList.remove('collapse'); dialogElement.classList.add('fade-out'); await waitForAnimationEnd(dialogElement); modalClosed();}
A utility method that returns a promise which is resolved the next time that the "animationend" or "transitionend" event is emitted from the provided
target
element. This makes it easy to string together multiple animations in sequence: