View source Improve this doc

$animate

service in module ng

Description

The $animate service provides rudimentary DOM manipulation functions to insert, remove and move elements within the DOM, as well as adding and removing classes. This service is the core service used by the ngAnimate $animator service which provides high-level animation hooks for CSS and JavaScript.

$animate is available in the AngularJS core, however, the ngAnimate module must be included to enable full out animation support. Otherwise, $animate will only perform simple DOM manipulation operations.

To learn more about enabling animation support, click here to visit the ngAnimate module page as well as the ngAnimate $animate service page.

Methods

  • addClass(element, className, done)

Adds the provided className CSS class value to the provided element. Once complete, the done() callback will be fired (if provided).

Parameters

ParamTypeDetailselementjQuery/jqLite element

the element which will have the className value added to it

classNamestring

the CSS class which will be added to the element

done (optional) function

the callback function (if provided) that will be fired after the className value has been added to the element

  • enter(element, parent, after, done)

Inserts the element into the DOM either after the after element or within the parent element. Once complete, the done() callback will be fired (if provided).

Parameters

ParamTypeDetailselementjQuery/jqLite element

the element which will be inserted into the DOM

parentjQuery/jqLite element

the parent element which will append the element as a child (if the after element is not present)

afterjQuery/jqLite element

the sibling element which will append the element after itself

done (optional) function

callback function that will be called after the element has been inserted into the DOM

  • leave(element, done)

Removes the element from the DOM. Once complete, the done() callback will be fired (if provided).

Parameters

ParamTypeDetailselementjQuery/jqLite element

the element which will be removed from the DOM

done (optional) function

callback function that will be called after the element has been removed from the DOM

  • move(element, parent, after, done)

Moves the position of the provided element within the DOM to be placed either after the after element or inside of the parent element. Once complete, the done() callback will be fired (if provided).

Parameters

ParamTypeDetailselementjQuery/jqLite element

the element which will be moved around within the DOM

parentjQuery/jqLite element

the parent element where the element will be inserted into (if the after element is not present)

afterjQuery/jqLite element

the sibling element where the element will be positioned next to

done (optional) function

the callback function (if provided) that will be fired after the element has been moved to its new position

  • removeClass(element, className, done)

Removes the provided className CSS class value from the provided element. Once complete, the done() callback will be fired (if provided).

Parameters

ParamTypeDetailselementjQuery/jqLite element

the element which will have the className value removed from it

classNamestring

the CSS class which will be removed from the element

done (optional) function

the callback function (if provided) that will be fired after the className value has been removed from the element