I have a defined CSS class spin that creates a simple CSS animation spinner on an element
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.spin {
animation: spin .8s linear .15s infinite;
}
The spin class is added and removed via JavaScript, however when the class is removed the animation abruptly cuts and the first frame is displayed. Is there are way to have the browser continue to animate the element until it reaches the last frame?
I tired doing multiple combinations of animation-fill-mode, or setting animation-iteration-count: 1 on the "resting" element (i.e., the same element when it does not have the spin class) but nothing worked. Any ideas how to make this work?