##AngularJS ngClass JavaScript Animation
When we click on the Toggle ngClass animation button, animationClass is added to the element with the firstJsAnimation class, so the ngAnimate module will check if there is an addClass animation callback function for elements with the firstJsAnimation class. If there is any, it will trigger the animation by calling the callback function.
AngularJS JavaScript animation works on the principle of callback functions. Each callback function has at least two parameters: element , which is the DOM element to be animated, and done , which is a callback function used to tell AngularJS when the animations are completed by calling it. We have passed the done function to jQuery's animate callback parameter in the sample; it's mandatory to call this function so that the $animate service knows when the animation is completed.
Each callback function can return an optional function that is called when the animation is completed or the execution has been canceled. We can tell whether the animation has been canceled or executed by the first parameter that is a Boolean; if that is true , it means that the animation has been cancelled and if it is false, it means the animation has been executed. In our samples, we added a treatment for cancelled animations, stopping the element jQuery animation. This might happen, for example, if you click twice on the Toggle ngClass animation button before the first animation has completed.