1
- // Type definitions for Angular JS 1.3 (ngAnimate module)
1
+ // Type definitions for Angular JS 1.5 (ngAnimate module)
2
2
// Project: http://angularjs.org
3
3
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
4
- // Definitions: https://github.com/borisyankov /DefinitelyTyped
4
+ // Definitions: https://github.com/DefinitelyTyped /DefinitelyTyped
5
5
6
6
/// <reference path="angular.d.ts" />
7
7
@@ -13,28 +13,69 @@ declare module "angular-animate" {
13
13
/**
14
14
* ngAnimate module (angular-animate.js)
15
15
*/
16
- declare module angular . animate {
17
- interface IAnimateFactory extends Function {
18
- enter ?: ( element : ng . IAugmentedJQuery , doneFn : Function ) => IAnimateCssRunner | void ;
19
- leave ?: ( element : ng . IAugmentedJQuery , doneFn : Function ) => IAnimateCssRunner | void ;
20
- addClass ?: ( element : ng . IAugmentedJQuery , className : string , doneFn : Function ) => IAnimateCssRunner | void ;
21
- removeClass ?: ( element : ng . IAugmentedJQuery , className : string , doneFn : Function ) => IAnimateCssRunner | void ;
22
- setClass ?: ( element : ng . IAugmentedJQuery , className : string , doneFn : Function ) => IAnimateCssRunner | void ;
16
+ declare namespace angular . animate {
17
+ interface IAnimateFactory {
18
+ ( ...args : any [ ] ) : IAnimateCallbackObject ;
23
19
}
24
20
21
+ interface IAnimateCallbackObject {
22
+ eventFn ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
23
+ setClass ?: ( element : IAugmentedJQuery , addedClasses : string , removedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
24
+ addClass ?: ( element : IAugmentedJQuery , addedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
25
+ removeClass ?: ( element : IAugmentedJQuery , removedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
26
+ enter ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
27
+ leave ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
28
+ move ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
29
+ animate ?: ( element : IAugmentedJQuery , fromStyles : string , toStyles : string , doneFunction : Function , options : IAnimationOptions ) => any ;
30
+ }
31
+
32
+ interface IAnimationPromise extends IPromise < void > { }
33
+
25
34
/**
26
35
* AnimateService
27
36
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
28
37
*/
29
38
interface IAnimateService {
39
+ /**
40
+ * Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children.
41
+ *
42
+ * @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
43
+ * @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
44
+ * @param callback the callback function that will be fired when the listener is triggered
45
+ */
46
+ on ( event : string , container : JQuery , callback : Function ) : void ;
47
+
48
+ /**
49
+ * Deregisters an event listener based on the event which has been associated with the provided element.
50
+ *
51
+ * @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
52
+ * @param container the container element the event listener was placed on
53
+ * @param callback the callback function that was registered as the listener
54
+ */
55
+ off ( event : string , container ?: JQuery , callback ?: Function ) : void ;
56
+
57
+ /**
58
+ * Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application.
59
+ *
60
+ * @param element the external element that will be pinned
61
+ * @param parentElement the host parent element that will be associated with the external element
62
+ */
63
+ pin ( element : JQuery , parentElement : JQuery ) : void ;
64
+
30
65
/**
31
66
* Globally enables / disables animations.
32
67
*
33
68
* @param element If provided then the element will be used to represent the enable/disable operation.
34
69
* @param value If provided then set the animation on or off.
35
70
* @returns current animation state
36
71
*/
37
- enabled ( element ?: JQuery , value ?: boolean ) : boolean ;
72
+ enabled ( element : JQuery , value ?: boolean ) : boolean ;
73
+ enabled ( value : boolean ) : boolean ;
74
+
75
+ /**
76
+ * Cancels the provided animation.
77
+ */
78
+ cancel ( animationPromise : IAnimationPromise ) : void ;
38
79
39
80
/**
40
81
* Performs an inline animation on the element.
@@ -46,7 +87,7 @@ declare module angular.animate {
46
87
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
47
88
* @returns the animation callback promise
48
89
*/
49
- animate ( element : JQuery , from : any , to : any , className ?: string , options ?: IAnimationOptions ) : IPromise < void > ;
90
+ animate ( element : JQuery , from : any , to : any , className ?: string , options ?: IAnimationOptions ) : IAnimationPromise ;
50
91
51
92
/**
52
93
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
@@ -57,7 +98,7 @@ declare module angular.animate {
57
98
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
58
99
* @returns the animation callback promise
59
100
*/
60
- enter ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery , options ?: IAnimationOptions ) : IPromise < void > ;
101
+ enter ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery , options ?: IAnimationOptions ) : IAnimationPromise ;
61
102
62
103
/**
63
104
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
@@ -66,7 +107,7 @@ declare module angular.animate {
66
107
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
67
108
* @returns the animation callback promise
68
109
*/
69
- leave ( element : JQuery , options ?: IAnimationOptions ) : IPromise < void > ;
110
+ leave ( element : JQuery , options ?: IAnimationOptions ) : IAnimationPromise ;
70
111
71
112
/**
72
113
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
@@ -78,7 +119,7 @@ declare module angular.animate {
78
119
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
79
120
* @returns the animation callback promise
80
121
*/
81
- move ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery ) : IPromise < void > ;
122
+ move ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery ) : IAnimationPromise ;
82
123
83
124
/**
84
125
* Triggers a custom animation event based off the className variable and then attaches the className
@@ -89,7 +130,7 @@ declare module angular.animate {
89
130
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
90
131
* @returns the animation callback promise
91
132
*/
92
- addClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IPromise < void > ;
133
+ addClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IAnimationPromise ;
93
134
94
135
/**
95
136
* Triggers a custom animation event based off the className variable and then removes the CSS class
@@ -100,7 +141,7 @@ declare module angular.animate {
100
141
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
101
142
* @returns the animation callback promise
102
143
*/
103
- removeClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IPromise < void > ;
144
+ removeClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IAnimationPromise ;
104
145
105
146
/**
106
147
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
@@ -112,12 +153,7 @@ declare module angular.animate {
112
153
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
113
154
* @returns the animation callback promise
114
155
*/
115
- setClass ( element : JQuery , add : string , remove : string , options ?: IAnimationOptions ) : IPromise < void > ;
116
-
117
- /**
118
- * Cancels the provided animation.
119
- */
120
- cancel ( animationPromise : IPromise < void > ) : void ;
156
+ setClass ( element : JQuery , add : string , remove : string , options ?: IAnimationOptions ) : IAnimationPromise ;
121
157
}
122
158
123
159
/**
@@ -131,7 +167,7 @@ declare module angular.animate {
131
167
* @param name The name of the animation.
132
168
* @param factory The factory function that will be executed to return the animation object.
133
169
*/
134
- register ( name : string , factory : ( ) => IAnimateCallbackObject ) : void ;
170
+ register ( name : string , factory : IAnimateFactory ) : void ;
135
171
136
172
/**
137
173
* Gets and/or sets the CSS class expression that is checked when performing an animation.
@@ -251,11 +287,13 @@ declare module angular.animate {
251
287
interface IAnimateCssService {
252
288
( element : JQuery , animateCssOptions : IAnimationOptions ) : IAnimateCssRunner ;
253
289
}
254
-
255
290
}
256
291
257
292
declare module angular {
258
293
interface IModule {
259
- animate ( cssSelector : string , animateFactory : angular . animate . IAnimateFactory ) : IModule ;
294
+ animation ( name : string , animationFactory : angular . animate . IAnimateFactory ) : IModule ;
295
+ animation ( name : string , inlineAnnotatedFunction : any [ ] ) : IModule ;
296
+ animation ( object : Object ) : IModule ;
260
297
}
298
+
261
299
}
0 commit comments