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

Closes #4463
Closes #3784