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

Commit 494277e

Browse files
committed
docs($animate): clarify possible options and fired events
1 parent e4339bc commit 494277e

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/ng/animate.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,39 @@ var $AnimateProvider = ['$provide', /** @this */ function($provide) {
369369
* );
370370
* ```
371371
*
372+
* <div class="alert alert-warning">
373+
* **Note**: Generally, the events that are fired correspond 1:1 to `$animate` method names,
374+
* e.g. {@link ng.$animate#addClass addClass()} will fire `addClass`, and {@link ng.ngClass}
375+
* will fire `addClass` if classes are added, and `removeClass` if classes are removed.
376+
* However, there are two exceptions:
377+
*
378+
* <ul>
379+
* <li>if both an {@link ng.$animate#addClass addClass()} and a
380+
* {@link ng.$animate#removeClass removeClass()} action are performed during the same
381+
* animation, the event fired will be `setClass`. This is true even for `ngClass`.</li>
382+
* <li>an {@link ng.$animate#animate animate()} call that adds and removes classes will fire
383+
* the `setClass` event, but if it either removes or adds classes,
384+
* it will fire `animate` instead.</li>
385+
* </ul>
386+
*
387+
* </div>
388+
*
372389
* @param {string} event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
373390
* @param {DOMElement} container the container element that will capture each of the animation events that are fired on itself
374391
* as well as among its children
375-
* @param {Function} callback the callback function that will be fired when the listener is triggered
392+
* @param {Function} callback the callback function that will be fired when the listener is triggered.
376393
*
377394
* The arguments present in the callback function are:
378395
* * `element` - The captured DOM element that the animation was fired on.
379396
* * `phase` - The phase of the animation. The two possible phases are **start** (when the animation starts) and **close** (when it ends).
397+
* * `data` - an object with these properties:
398+
* * addClass - `{string|null}` - space-separated CSS classes to add to the element
399+
* * removeClass - `{string|null}` - space-separated CSS classes to remove from the element
400+
* * from - `{Object|null}` - CSS properties & values at the beginning of the animation
401+
* * to - `{Object|null}` - CSS properties & values at the end of the animation
402+
*
403+
* Note that the callback does not trigger a scope digest. Wrap your call into a
404+
* {@link $rootScope.Scope#$apply scope.$apply} to propagate changes to the scope.
380405
*/
381406
on: $$animateQueue.on,
382407

@@ -644,9 +669,8 @@ var $AnimateProvider = ['$provide', /** @this */ function($provide) {
644669
* @param {object=} options an optional collection of options/styles that will be applied to the element.
645670
* The object can have the following properties:
646671
*
647-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
648-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
649672
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
673+
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
650674
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
651675
*
652676
* @return {Runner} animationRunner the animation runner
@@ -676,7 +700,6 @@ var $AnimateProvider = ['$provide', /** @this */ function($provide) {
676700
*
677701
* - **addClass** - `{string}` - space-separated CSS classes to add to element
678702
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
679-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
680703
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
681704
*
682705
* @return {Runner} the animation runner
@@ -706,8 +729,8 @@ var $AnimateProvider = ['$provide', /** @this */ function($provide) {
706729
* The object can have the following properties:
707730
*
708731
* - **addClass** - `{string}` - space-separated CSS classes to add to element
709-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
710732
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
733+
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
711734
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
712735
*
713736
* @return {Runner} the animation runner

src/ng/directive/ngClass.js

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ function classDirective(name, selector) {
178178
* |----------------------------------|-------------------------------------|
179179
* | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
180180
* | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
181+
* | {@link ng.$animate#setClass setClass} | just before classes are added and classes are removed from the element at the same time |
181182
*
182183
* ### ngClass and pre-existing CSS3 Transitions/Animations
183184
The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.

0 commit comments

Comments
 (0)