From aaa4710e6383fb67294e083675f48dafa005715f Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Tue, 7 Oct 2014 12:15:55 -0400 Subject: [PATCH 1/6] Add definitions for $animateProvider in angularjs As per the docs [here](https://docs.angularjs.org/api/ng/provider/$animateProvider). --- angularjs/angular-animate.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 9503e36d75..d4ec6eea2a 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -18,4 +18,23 @@ declare module ng.animate { interface IAnimateService extends ng.IAnimateService { enabled(value?: boolean, element?: JQuery): boolean; } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + */ + register(name: string, factory: () => IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + */ + classNameFilter(expression?: RegExp): RegExp; + } } From 69ec24c5e94a0eebf9b7bc9857f4586fcc3ca93a Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Tue, 7 Oct 2014 23:56:38 -0400 Subject: [PATCH 2/6] Add default $animateProvider in angular.d.ts --- angularjs/angular-animate.d.ts | 12 +++++++++++- angularjs/angular.d.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index d4ec6eea2a..2e80ceca27 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -26,14 +26,24 @@ declare module ng.animate { eventFn(element: Node, doneFn: () => void): Function; } + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// interface IAnimateProvider { /** * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. */ - register(name: string, factory: () => IAnimateCallbackObject): void; + register(name: string, factory: () => ng.IAnimateCallbackObject); /** * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. */ classNameFilter(expression?: RegExp): RegExp; } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 7bc1672840..074e980e48 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -594,6 +594,35 @@ declare module ng { cancel(promise: IPromise): boolean; } + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see http://docs.angularjs.org/api/ng/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => IAnimateCallbackObject); + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + /////////////////////////////////////////////////////////////////////////// // FilterService // see http://docs.angularjs.org/api/ng.$filter From e00a5588ee25b2c946db2e87966703ae1ed20cb4 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Tue, 7 Oct 2014 23:57:05 -0400 Subject: [PATCH 3/6] Improve $animate service typings --- angularjs/angular-animate.d.ts | 82 ++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 2e80ceca27..e725a1313c 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS 1.2+ (ngAnimate module) // Project: http://angularjs.org -// Definitions by: Michel Salib +// Definitions by: Michel Salib , Adi Dahiya // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -13,17 +13,83 @@ declare module ng.animate { /////////////////////////////////////////////////////////////////////////// // AnimateService - // see http://docs.angularjs.org/api/ngAnimate.$animate + // see http://docs.angularjs.org/api/ngAnimate/service/$animate /////////////////////////////////////////////////////////////////////////// interface IAnimateService extends ng.IAnimateService { + /** + * Globally enables / disables animations. + * + * @param value If provided then set the animation on or off. + * @param element If provided then the element will be used to represent the enable/disable operation. + * @returns current animation state + */ enabled(value?: boolean, element?: JQuery): boolean; - } - /** - * The animation object which contains callback functions for each event that is expected to be animated. - */ - interface IAnimateCallbackObject { - eventFn(element: Node, doneFn: () => void): Function; + /** + * Appends the element to the parentElement element that resides in the document and then runs the enter animation. + * + * @param element the element that will be the focus of the enter animation + * @param parentElement the parent element of the element that will be the focus of the enter animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation + * @returns the animation callback promise + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; + + /** + * Runs the leave animation operation and, upon completion, removes the element from the DOM. + * + * @param element the element that will be the focus of the leave animation + * @returns the animation callback promise + */ + leave(element: JQuery): ng.IPromise; + + /** + * Fires the move DOM operation. Just before the animation starts, the animate service will either append + * it into the parentElement container or add the element directly after the afterElement element if present. + * Then the move animation will be run. + * + * @param element the element that will be the focus of the move animation + * @param parentElement the parent element of the element that will be the focus of the move animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation + * @returns the animation callback promise + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; + + /** + * Triggers a custom animation event based off the className variable and then attaches the className + * value to the element as a CSS class. + * + * @param element the element that will be animated + * @param className the CSS class that will be added to the element and then animated + * @returns the animation callback promise + */ + addClass(element: JQuery, className: string): ng.IPromise; + + /** + * Triggers a custom animation event based off the className variable and then removes the CSS class + * provided by the className value from the element. + * + * @param element the element that will be animated + * @param className the CSS class that will be animated and then removed from the element + * @returns the animation callback promise + */ + removeClass(element: JQuery, className: string): ng.IPromise; + + /** + * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback + * will be fired (if provided). + * + * @param element the element which will have its CSS classes changed removed from it + * @param add the CSS classes which will be added to the element + * @param remove the CSS class which will be removed from the element CSS classes have been set on the element + * @returns the animation callback promise + */ + setClass(element: JQuery, add: string, remove: string): ng.IPromise; + + /** + * Cancels the provided animation. + */ + cancel(animationPromise: ng.IPromise); } /////////////////////////////////////////////////////////////////////////// From 05432c972c059656035392b44f9b51d094bee32b Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Wed, 8 Oct 2014 00:01:10 -0400 Subject: [PATCH 4/6] Add return type to register fn in $animateProvider --- angularjs/angular-animate.d.ts | 2 +- angularjs/angular.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index e725a1313c..e3801218b2 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -103,7 +103,7 @@ declare module ng.animate { * @param name The name of the animation. * @param factory The factory function that will be executed to return the animation object. */ - register(name: string, factory: () => ng.IAnimateCallbackObject); + register(name: string, factory: () => ng.IAnimateCallbackObject): void; /** * Gets and/or sets the CSS class expression that is checked when performing an animation. diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 074e980e48..20e6878949 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -605,7 +605,7 @@ declare module ng { * @param name The name of the animation. * @param factory The factory function that will be executed to return the animation object. */ - register(name: string, factory: () => IAnimateCallbackObject); + register(name: string, factory: () => IAnimateCallbackObject): void; /** * Gets and/or sets the CSS class expression that is checked when performing an animation. From df4413992a4d9fe3ea5d12113394fc464324e0d3 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Wed, 8 Oct 2014 00:06:13 -0400 Subject: [PATCH 5/6] Add return type to cancel fn in $animate --- angularjs/angular-animate.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index e3801218b2..8bdb6500e8 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -89,7 +89,7 @@ declare module ng.animate { /** * Cancels the provided animation. */ - cancel(animationPromise: ng.IPromise); + cancel(animationPromise: ng.IPromise): void; } /////////////////////////////////////////////////////////////////////////// From 8d6654ebf35a1a1b2279d51059f20f0b06d1acb3 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Fri, 10 Oct 2014 10:50:57 -0400 Subject: [PATCH 6/6] Fix 'move' method name in angularjs $animate service typings --- angularjs/angular-animate.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 8bdb6500e8..aa12399e5e 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -53,7 +53,7 @@ declare module ng.animate { * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation * @returns the animation callback promise */ - enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; /** * Triggers a custom animation event based off the className variable and then attaches the className