throttling, debouncing, setInterval and requestAnimationFrame

Removing the animation-name applied to an element will make it jump or cut to its next state. If instead you'd like the animation to complete and then come to a stop you have to try a different approach. The main tricks are:


some event {
 
 el.classList.remove(animation); // kills the animation, and takes it to the next state
 
 window.setTimeout(function(e) {
  el.classList.add(animation); // add it back 1 ms after removing it, thus restarting the animation
 }, 1);

}