How to check whether a CSS3 transition of an element has started or end with JavaScript?

Sometimes, we want to check whether a CSS3 transition of an element has started or end with JavaScript.

In this article, we’ll look at how to check whether a CSS3 transition of an element has started or end with JavaScript.

How to check whether a CSS3 transition of an element has started or end with JavaScript?

To check whether a CSS3 transition of an element has started or end with JavaScript, we listen to the transitionend event.

For instance, we write

element.addEventListener("transitionend", callback, false);

to listen to the transitionend event emitted by element with addEventListener

callback is called when the transition is finished.

Conclusion

To check whether a CSS3 transition of an element has started or end with JavaScript, we listen to the transitionend event.