Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9f3935b

Browse files
matskomhevery
authored andcommitted
chore(ngdocs): provide docs for the core $animator service
1 parent 2e72239 commit 9f3935b

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

src/ng/animate.js

+85
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,39 @@ var $AnimateProvider = ['$provide', function($provide) {
5757
};
5858

5959
this.$get = ['$timeout', function($timeout) {
60+
61+
/**
62+
* @ngdoc object
63+
* @name ng.$animate
64+
*
65+
* @description
66+
* The $animate service provides rudimentary DOM manipulation functions to insert, remove, move elements within
67+
* the DOM as well as adding and removing classes. This service is the core service used by the ngAnimate $animator
68+
* service which provides high-level animation hooks for CSS and JavaScript.
69+
*
70+
* $animate is available in the AngularJS core, however, the ngAnimate module must be included to enable full out
71+
* animation support. Otherwise, $animate will only perform simple DOM manipulation operations.
72+
*
73+
* To learn more about enabling animation support, click here to visit the {@link ngAnimate ngAnimate module page}
74+
* as well as the {@link ngAnimate.$animate ngAnimate $animate service page}.
75+
*/
6076
return {
77+
78+
/**
79+
* @ngdoc function
80+
* @name ng.$animate#enter
81+
* @methodOf ng.$animate
82+
* @function
83+
*
84+
* @description
85+
* Inserts the element into the DOM either after the `after` element or within the `parent` element. Once complete,
86+
* the done() callback will be fired (if provided).
87+
*
88+
* @param {jQuery/jqLite element} element the element which will be inserted into the DOM
89+
* @param {jQuery/jqLite element} parent the parent element which will append the element as a child (if the after element is not present)
90+
* @param {jQuery/jqLite element} after the sibling element which will append the element after itself
91+
* @param {function=} done callback function that will be called after the element has been inserted into the DOM
92+
*/
6193
enter : function(element, parent, after, done) {
6294
var afterNode = after && after[after.length - 1];
6395
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
@@ -69,17 +101,57 @@ var $AnimateProvider = ['$provide', function($provide) {
69101
$timeout(done || noop, 0, false);
70102
},
71103

104+
/**
105+
* @ngdoc function
106+
* @name ng.$animate#leave
107+
* @methodOf ng.$animate
108+
* @function
109+
*
110+
* @description
111+
* Removes the element from the DOM. Once complete, the done() callback will be fired (if provided).
112+
*
113+
* @param {jQuery/jqLite element} element the element which will be removed from the DOM
114+
* @param {function=} done callback function that will be called after the element has been removed from the DOM
115+
*/
72116
leave : function(element, done) {
73117
element.remove();
74118
$timeout(done || noop, 0, false);
75119
},
76120

121+
/**
122+
* @ngdoc function
123+
* @name ng.$animate#move
124+
* @methodOf ng.$animate
125+
* @function
126+
*
127+
* @description
128+
* Moves the position of the provided element within the DOM to be placed either after the `after` element or inside of the `parent` element.
129+
* Once complete, the done() callback will be fired (if provided).
130+
*
131+
* @param {jQuery/jqLite element} element the element which will be moved around within the DOM
132+
* @param {jQuery/jqLite element} parent the parent element where the element will be inserted into (if the after element is not present)
133+
* @param {jQuery/jqLite element} after the sibling element where the element will be positioned next to
134+
* @param {function=} done the callback function (if provided) that will be fired after the element has been moved to it's new position
135+
*/
77136
move : function(element, parent, after, done) {
78137
// Do not remove element before insert. Removing will cause data associated with the
79138
// element to be dropped. Insert will implicitly do the remove.
80139
this.enter(element, parent, after, done);
81140
},
82141

142+
/**
143+
* @ngdoc function
144+
* @name ng.$animate#addClass
145+
* @methodOf ng.$animate
146+
* @function
147+
*
148+
* @description
149+
* Adds the provided className CSS class value to the provided element. Once complete, the done() callback will be fired (if provided).
150+
*
151+
* @param {jQuery/jqLite element} element the element which will have the className value added to it
152+
* @param {string} className the CSS class which will be added to the element
153+
* @param {function=} done the callback function (if provided) that will be fired after the className value has been added to the element
154+
*/
83155
addClass : function(element, className, done) {
84156
className = isString(className) ?
85157
className :
@@ -88,6 +160,19 @@ var $AnimateProvider = ['$provide', function($provide) {
88160
$timeout(done || noop, 0, false);
89161
},
90162

163+
/**
164+
* @ngdoc function
165+
* @name ng.$animate#removeClass
166+
* @methodOf ng.$animate
167+
* @function
168+
*
169+
* @description
170+
* Removes the provided className CSS class value from the provided element. Once complete, the done() callback will be fired (if provided).
171+
*
172+
* @param {jQuery/jqLite element} element the element which will have the className value removed from it
173+
* @param {string} className the CSS class which will be removed from the element
174+
* @param {function=} done the callback function (if provided) that will be fired after the className value has been removed from the element
175+
*/
91176
removeClass : function(element, className, done) {
92177
className = isString(className) ?
93178
className :

0 commit comments

Comments
 (0)