fix($animate): prevent race conditions for class-based animations when animating on the same CSS class

Closes #5588