fix($animate): only cancel class-based animations if the follow-up class contains animation code

Closes #4463
Closes #3784