mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-28 12:55:48 +08:00
chore(ngdocs): provide docs for the core $animator service
This commit is contained in:
committed by
Misko Hevery
parent
2e72239133
commit
9f3935baff
@@ -57,7 +57,39 @@ var $AnimateProvider = ['$provide', function($provide) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.$get = ['$timeout', function($timeout) {
|
this.$get = ['$timeout', function($timeout) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc object
|
||||||
|
* @name ng.$animate
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* The $animate service provides rudimentary DOM manipulation functions to insert, remove, 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 {@link ngAnimate ngAnimate module page}
|
||||||
|
* as well as the {@link ngAnimate.$animate ngAnimate $animate service page}.
|
||||||
|
*/
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.$animate#enter
|
||||||
|
* @methodOf ng.$animate
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* 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).
|
||||||
|
*
|
||||||
|
* @param {jQuery/jqLite element} element the element which will be inserted into the DOM
|
||||||
|
* @param {jQuery/jqLite element} parent the parent element which will append the element as a child (if the after element is not present)
|
||||||
|
* @param {jQuery/jqLite element} after the sibling element which will append the element after itself
|
||||||
|
* @param {function=} done callback function that will be called after the element has been inserted into the DOM
|
||||||
|
*/
|
||||||
enter : function(element, parent, after, done) {
|
enter : function(element, parent, after, done) {
|
||||||
var afterNode = after && after[after.length - 1];
|
var afterNode = after && after[after.length - 1];
|
||||||
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
|
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
|
||||||
@@ -69,17 +101,57 @@ var $AnimateProvider = ['$provide', function($provide) {
|
|||||||
$timeout(done || noop, 0, false);
|
$timeout(done || noop, 0, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.$animate#leave
|
||||||
|
* @methodOf ng.$animate
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Removes the element from the DOM. Once complete, the done() callback will be fired (if provided).
|
||||||
|
*
|
||||||
|
* @param {jQuery/jqLite element} element the element which will be removed from the DOM
|
||||||
|
* @param {function=} done callback function that will be called after the element has been removed from the DOM
|
||||||
|
*/
|
||||||
leave : function(element, done) {
|
leave : function(element, done) {
|
||||||
element.remove();
|
element.remove();
|
||||||
$timeout(done || noop, 0, false);
|
$timeout(done || noop, 0, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.$animate#move
|
||||||
|
* @methodOf ng.$animate
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* 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).
|
||||||
|
*
|
||||||
|
* @param {jQuery/jqLite element} element the element which will be moved around within the DOM
|
||||||
|
* @param {jQuery/jqLite element} parent the parent element where the element will be inserted into (if the after element is not present)
|
||||||
|
* @param {jQuery/jqLite element} after the sibling element where the element will be positioned next to
|
||||||
|
* @param {function=} done the callback function (if provided) that will be fired after the element has been moved to it's new position
|
||||||
|
*/
|
||||||
move : function(element, parent, after, done) {
|
move : function(element, parent, after, done) {
|
||||||
// Do not remove element before insert. Removing will cause data associated with the
|
// Do not remove element before insert. Removing will cause data associated with the
|
||||||
// element to be dropped. Insert will implicitly do the remove.
|
// element to be dropped. Insert will implicitly do the remove.
|
||||||
this.enter(element, parent, after, done);
|
this.enter(element, parent, after, done);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.$animate#addClass
|
||||||
|
* @methodOf ng.$animate
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Adds the provided className CSS class value to the provided element. Once complete, the done() callback will be fired (if provided).
|
||||||
|
*
|
||||||
|
* @param {jQuery/jqLite element} element the element which will have the className value added to it
|
||||||
|
* @param {string} className the CSS class which will be added to the element
|
||||||
|
* @param {function=} done the callback function (if provided) that will be fired after the className value has been added to the element
|
||||||
|
*/
|
||||||
addClass : function(element, className, done) {
|
addClass : function(element, className, done) {
|
||||||
className = isString(className) ?
|
className = isString(className) ?
|
||||||
className :
|
className :
|
||||||
@@ -88,6 +160,19 @@ var $AnimateProvider = ['$provide', function($provide) {
|
|||||||
$timeout(done || noop, 0, false);
|
$timeout(done || noop, 0, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.$animate#removeClass
|
||||||
|
* @methodOf ng.$animate
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Removes the provided className CSS class value from the provided element. Once complete, the done() callback will be fired (if provided).
|
||||||
|
*
|
||||||
|
* @param {jQuery/jqLite element} element the element which will have the className value removed from it
|
||||||
|
* @param {string} className the CSS class which will be removed from the element
|
||||||
|
* @param {function=} done the callback function (if provided) that will be fired after the className value has been removed from the element
|
||||||
|
*/
|
||||||
removeClass : function(element, className, done) {
|
removeClass : function(element, className, done) {
|
||||||
className = isString(className) ?
|
className = isString(className) ?
|
||||||
className :
|
className :
|
||||||
|
|||||||
Reference in New Issue
Block a user