1
+ // Type definitions for Angular JS 1.5 (ngAnimate module)
2
+ // Project: http://angularjs.org
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/DefinitelyTyped/DefinitelyTyped
5
+
6
+ /// <reference types="jquery" />
7
+
8
+ declare var _ : string ;
9
+ export = _ ;
10
+
11
+ import * as angular from 'angular' ;
12
+
13
+ declare module 'angular' {
14
+ /**
15
+ * ngAnimate module (angular-animate.js)
16
+ */
17
+ namespace animate {
18
+ interface IAnimateFactory {
19
+ ( ...args : any [ ] ) : IAnimateCallbackObject ;
20
+ }
21
+
22
+ interface IAnimateCallbackObject {
23
+ eventFn ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
24
+ setClass ?: ( element : IAugmentedJQuery , addedClasses : string , removedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
25
+ addClass ?: ( element : IAugmentedJQuery , addedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
26
+ removeClass ?: ( element : IAugmentedJQuery , removedClasses : string , doneFunction : Function , options : IAnimationOptions ) => any ;
27
+ enter ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
28
+ leave ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
29
+ move ?: ( element : IAugmentedJQuery , doneFunction : Function , options : IAnimationOptions ) => any ;
30
+ animate ?: ( element : IAugmentedJQuery , fromStyles : string , toStyles : string , doneFunction : Function , options : IAnimationOptions ) => any ;
31
+ }
32
+
33
+ interface IAnimationPromise extends IPromise < void > { }
34
+
35
+ /**
36
+ * AnimateService
37
+ * see http://docs.angularjs.org/api/ngAnimate/service/$animate
38
+ */
39
+ interface IAnimateService {
40
+ /**
41
+ * Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children.
42
+ *
43
+ * @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
44
+ * @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
45
+ * @param callback the callback function that will be fired when the listener is triggered
46
+ */
47
+ on ( event : string , container : JQuery , callback : Function ) : void ;
48
+
49
+ /**
50
+ * Deregisters an event listener based on the event which has been associated with the provided element.
51
+ *
52
+ * @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
53
+ * @param container the container element the event listener was placed on
54
+ * @param callback the callback function that was registered as the listener
55
+ */
56
+ off ( event : string , container ?: JQuery , callback ?: Function ) : void ;
57
+
58
+ /**
59
+ * 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.
60
+ *
61
+ * @param element the external element that will be pinned
62
+ * @param parentElement the host parent element that will be associated with the external element
63
+ */
64
+ pin ( element : JQuery , parentElement : JQuery ) : void ;
65
+
66
+ /**
67
+ * Globally enables / disables animations.
68
+ *
69
+ * @param element If provided then the element will be used to represent the enable/disable operation.
70
+ * @param value If provided then set the animation on or off.
71
+ * @returns current animation state
72
+ */
73
+ enabled ( element : JQuery , value ?: boolean ) : boolean ;
74
+ enabled ( value : boolean ) : boolean ;
75
+
76
+ /**
77
+ * Cancels the provided animation.
78
+ */
79
+ cancel ( animationPromise : IAnimationPromise ) : void ;
80
+
81
+ /**
82
+ * Performs an inline animation on the element.
83
+ *
84
+ * @param element the element that will be the focus of the animation
85
+ * @param from a collection of CSS styles that will be applied to the element at the start of the animation
86
+ * @param to a collection of CSS styles that the element will animate towards
87
+ * @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate')
88
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
89
+ * @returns the animation callback promise
90
+ */
91
+ animate ( element : JQuery , from : any , to : any , className ?: string , options ?: IAnimationOptions ) : IAnimationPromise ;
92
+
93
+ /**
94
+ * Appends the element to the parentElement element that resides in the document and then runs the enter animation.
95
+ *
96
+ * @param element the element that will be the focus of the enter animation
97
+ * @param parentElement the parent element of the element that will be the focus of the enter animation
98
+ * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
99
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
100
+ * @returns the animation callback promise
101
+ */
102
+ enter ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery , options ?: IAnimationOptions ) : IAnimationPromise ;
103
+
104
+ /**
105
+ * Runs the leave animation operation and, upon completion, removes the element from the DOM.
106
+ *
107
+ * @param element the element that will be the focus of the leave animation
108
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
109
+ * @returns the animation callback promise
110
+ */
111
+ leave ( element : JQuery , options ?: IAnimationOptions ) : IAnimationPromise ;
112
+
113
+ /**
114
+ * Fires the move DOM operation. Just before the animation starts, the animate service will either append
115
+ * it into the parentElement container or add the element directly after the afterElement element if present.
116
+ * Then the move animation will be run.
117
+ *
118
+ * @param element the element that will be the focus of the move animation
119
+ * @param parentElement the parent element of the element that will be the focus of the move animation
120
+ * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
121
+ * @returns the animation callback promise
122
+ */
123
+ move ( element : JQuery , parentElement : JQuery , afterElement ?: JQuery ) : IAnimationPromise ;
124
+
125
+ /**
126
+ * Triggers a custom animation event based off the className variable and then attaches the className
127
+ * value to the element as a CSS class.
128
+ *
129
+ * @param element the element that will be animated
130
+ * @param className the CSS class that will be added to the element and then animated
131
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
132
+ * @returns the animation callback promise
133
+ */
134
+ addClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IAnimationPromise ;
135
+
136
+ /**
137
+ * Triggers a custom animation event based off the className variable and then removes the CSS class
138
+ * provided by the className value from the element.
139
+ *
140
+ * @param element the element that will be animated
141
+ * @param className the CSS class that will be animated and then removed from the element
142
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
143
+ * @returns the animation callback promise
144
+ */
145
+ removeClass ( element : JQuery , className : string , options ?: IAnimationOptions ) : IAnimationPromise ;
146
+
147
+ /**
148
+ * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
149
+ * will be fired (if provided).
150
+ *
151
+ * @param element the element which will have its CSS classes changed removed from it
152
+ * @param add the CSS classes which will be added to the element
153
+ * @param remove the CSS class which will be removed from the element CSS classes have been set on the element
154
+ * @param options an optional collection of styles that will be picked up by the CSS transition/animation
155
+ * @returns the animation callback promise
156
+ */
157
+ setClass ( element : JQuery , add : string , remove : string , options ?: IAnimationOptions ) : IAnimationPromise ;
158
+ }
159
+
160
+ /**
161
+ * AnimateProvider
162
+ * see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
163
+ */
164
+ interface IAnimateProvider {
165
+ /**
166
+ * Registers a new injectable animation factory function.
167
+ *
168
+ * @param name The name of the animation.
169
+ * @param factory The factory function that will be executed to return the animation object.
170
+ */
171
+ register ( name : string , factory : IAnimateFactory ) : void ;
172
+
173
+ /**
174
+ * Gets and/or sets the CSS class expression that is checked when performing an animation.
175
+ *
176
+ * @param expression The className expression which will be checked against all animations.
177
+ * @returns The current CSS className expression value. If null then there is no expression value.
178
+ */
179
+ classNameFilter ( expression ?: RegExp ) : RegExp ;
180
+ }
181
+
182
+ /**
183
+ * Angular Animation Options
184
+ * see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation
185
+ */
186
+ interface IAnimationOptions {
187
+ /**
188
+ * The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
189
+ */
190
+ to ?: Object ;
191
+
192
+ /**
193
+ * The starting CSS styles (a key/value object) that will be applied at the start of the animation.
194
+ */
195
+ from ?: Object ;
196
+
197
+ /**
198
+ * The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and
199
+ * ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when
200
+ * spaces are used as a separator. (Note that this will not perform any DOM operation.)
201
+ */
202
+ event ?: string ;
203
+
204
+ /**
205
+ * The CSS easing value that will be applied to the transition or keyframe animation (or both).
206
+ */
207
+ easing ?: string ;
208
+
209
+ /**
210
+ * The raw CSS transition style that will be used (e.g. 1s linear all).
211
+ */
212
+ transition ?: string ;
213
+
214
+ /**
215
+ * The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear).
216
+ */
217
+ keyframe ?: string ;
218
+
219
+ /**
220
+ * A space separated list of CSS classes that will be added to the element and spread across the animation.
221
+ */
222
+ addClass ?: string ;
223
+
224
+ /**
225
+ * A space separated list of CSS classes that will be removed from the element and spread across
226
+ * the animation.
227
+ */
228
+ removeClass ?: string ;
229
+
230
+ /**
231
+ * A number value representing the total duration of the transition and/or keyframe (note that a value
232
+ * of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely.
233
+ */
234
+ duration ?: number ;
235
+
236
+ /**
237
+ * A number value representing the total delay of the transition and/or keyframe (note that a value of
238
+ * 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be
239
+ * mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be
240
+ * transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to
241
+ * all share the same CSS delay value.
242
+ */
243
+ delay ?: number ;
244
+
245
+ /**
246
+ * A numeric time value representing the delay between successively animated elements (Click here to
247
+ * learn how CSS-based staggering works in ngAnimate.)
248
+ */
249
+ stagger ?: number ;
250
+
251
+ /**
252
+ * The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item
253
+ * in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms)
254
+ * applyClassesEarly - Whether or not the classes being added or removed will be used when detecting the animation.
255
+ * This is set by $animate when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time.
256
+ * (Note that this will prevent any transitions from occuring on the classes being added and removed.)
257
+ */
258
+ staggerIndex ?: number ;
259
+ }
260
+
261
+ interface IAnimateCssRunner {
262
+ /**
263
+ * Starts the animation
264
+ *
265
+ * @returns The animation runner with a done function for supplying a callback.
266
+ */
267
+ start ( ) : IAnimateCssRunnerStart ;
268
+
269
+ /**
270
+ * Ends (aborts) the animation
271
+ */
272
+ end ( ) : void ;
273
+ }
274
+
275
+ interface IAnimateCssRunnerStart extends IPromise < void > {
276
+ /**
277
+ * Allows you to add done callbacks to the running animation
278
+ *
279
+ * @param callbackFn: the callback function to be run
280
+ */
281
+ done ( callbackFn : ( animationFinished : boolean ) => void ) : void ;
282
+ }
283
+
284
+ /**
285
+ * AnimateCssService
286
+ * see http://docs.angularjs.org/api/ngAnimate/service/$animateCss
287
+ */
288
+ interface IAnimateCssService {
289
+ ( element : JQuery , animateCssOptions : IAnimationOptions ) : IAnimateCssRunner ;
290
+ }
291
+ }
292
+
293
+ interface IModule {
294
+ animation ( name : string , animationFactory : angular . animate . IAnimateFactory ) : IModule ;
295
+ animation ( name : string , inlineAnnotatedFunction : any [ ] ) : IModule ;
296
+ animation ( object : Object ) : IModule ;
297
+ }
298
+ }
0 commit comments