About CSS Transition Start and End Events

When you use CSS animations, you can track by JavaScript, when the transition started and ended. Do that with transitionstart and transitionend events, as follows:

1
2
3
4
5
6
7
8
9
const el = document.querySelector('.animated');

el.addEventListener('transitionstart', function() {
    console.log('Animation started');
});

el.addEventListener('transitionend', function() {
    console.log('Animation ended');
});

Tips and Tricks Programming Web Design JavaScript HTML5 CSS3