Skip to content

Commit e050e9f

Browse files
Theodore Browntheodorejb
authored andcommitted
Include TypeScript definitions
1 parent 69ce5b7 commit e050e9f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

js/ladda.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export interface LaddaButton {
2+
start(): LaddaButton,
3+
startAfter(delay: number): LaddaButton,
4+
stop(): LaddaButton,
5+
toggle(): LaddaButton,
6+
setProgress(progress: number): void,
7+
isLoading(): boolean,
8+
remove(): void,
9+
}
10+
11+
export interface BindOptions {
12+
/**
13+
* Number of milliseconds to wait before automatically cancelling the animation.
14+
*/
15+
timeout?: number,
16+
17+
/**
18+
* A function to be called with the Ladda instance when a target button is clicked.
19+
*/
20+
callback?: (instance: LaddaButton) => void,
21+
}
22+
23+
/**
24+
* Creates a new instance of Ladda which wraps the target button element.
25+
*/
26+
export function create(button: HTMLButtonElement): LaddaButton;
27+
28+
/**
29+
* Binds the target buttons to automatically enter the loading state when clicked.
30+
* @param target Either an HTML element or a CSS selector.
31+
*/
32+
export function bind(target: HTMLElement | string, options?: BindOptions): void;
33+
34+
/**
35+
* Stops all current loading animations.
36+
*/
37+
export function stopAll(): void;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Buttons with built-in loading indicators",
55
"homepage": "http://lab.hakim.se/ladda",
66
"main": "./js/ladda.js",
7+
"types": "./js/ladda.d.ts",
78
"scripts": {
89
"test": "grunt jshint",
910
"prepare": "grunt && rollup -c",

0 commit comments

Comments
 (0)