Improve this Doc View Source $animate
- $animateProvider
- service in module ng
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
-
enter(element, parent, after, [options]);
Inserts the element into the DOM either after the
after
element or as the first child within theparent
element. When the function is called a promise is returned that will be resolved at a later time.Parameters
Param Type Details element DOMElement
the element which will be inserted into the DOM
parent DOMElement
the parent element which will append the element as a child (if the after element is not present)
after DOMElement
the sibling element which will append the element after itself
options (optional)object
an optional collection of styles that will be applied to the element.
Returns
Promise
the animation callback promise
-
leave(element, [options]);
Removes the element from the DOM. When the function is called a promise is returned that will be resolved at a later time.
Parameters
Param Type Details element DOMElement
the element which will be removed from the DOM
options (optional)object
an optional collection of options that will be applied to the element.
Returns
Promise
the animation callback promise
-
move(element, parent, after, [options]);
Moves the position of the provided element within the DOM to be placed either after the
after
element or inside of theparent
element. When the function is called a promise is returned that will be resolved at a later time.Parameters
Param Type Details element DOMElement
the element which will be moved around within the DOM
parent DOMElement
the parent element where the element will be inserted into (if the after element is not present)
after DOMElement
the sibling element where the element will be positioned next to
options (optional)object
an optional collection of options that will be applied to the element.
Returns
Promise
the animation callback promise
-
addClass(element, className, [options]);
Adds the provided className CSS class value to the provided element. When the function is called a promise is returned that will be resolved at a later time.
Parameters
Param Type Details element DOMElement
the element which will have the className value added to it
className string
the CSS class which will be added to the element
options (optional)object
an optional collection of options that will be applied to the element.
Returns
Promise
the animation callback promise
-
removeClass(element, className, [options]);
Removes the provided className CSS class value from the provided element. When the function is called a promise is returned that will be resolved at a later time.
Parameters
Param Type Details element DOMElement
the element which will have the className value removed from it
className string
the CSS class which will be removed from the element
options (optional)object
an optional collection of options that will be applied to the element.
Returns
Promise
the animation callback promise
-
setClass(element, add, remove, [options]);
Adds and/or removes the given CSS classes to and from the element. When the function is called a promise is returned that will be resolved at a later time.
Parameters
Param Type Details element DOMElement
the element which will have its CSS classes changed removed from it
add string
the CSS classes which will be added to the element
remove string
the CSS class which will be removed from the element
options (optional)object
an optional collection of options that will be applied to the element.
Returns
Promise
the animation callback promise
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.3.20/docs/api/ng/service/$animate