reset animation iteration count javascript

Solutions on MaxInterview for reset animation iteration count javascript by the best coders in the world

showing results for - "reset animation iteration count javascript"
Leon
27 Sep 2019
1// retrieve the element
2element = document.getElementById("logo");
3
4// reset the transition by...
5element.addEventListener("click", function(e) {
6  e.preventDefault;
7  
8  // -> removing the class
9  element.classList.remove("run-animation");
10  
11  // -> triggering reflow /* The actual magic */
12  // without this it wouldn't work. Try uncommenting the line and the transition won't be retriggered.
13  // Oops! This won't work in strict mode. Thanks Felis Phasma!
14  // element.offsetWidth = element.offsetWidth;
15  // Do this instead:
16  void element.offsetWidth;
17  
18  // -> and re-adding the class
19  element.classList.add("run-animation");
20}, false);