-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
index.d.ts
257 lines (255 loc) · 6.19 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/**
* Welcome to Typed.js!
* @param {string} elementId HTML element ID _OR_ HTML element
* @param {object} options options object
* @returns {object} a new Typed object
*/
declare module 'typed.js' {
export interface TypedOptions {
/**
* strings to be typed
*/
strings?: string[];
/**
* ID or instance of HTML element of element containing string children
*/
stringsElement?: string | Element;
/**
* type speed in milliseconds
*/
typeSpeed?: number;
/**
* time before typing starts in milliseconds
*/
startDelay?: number;
/**
* backspacing speed in milliseconds
*/
backSpeed?: number;
/**
* only backspace what doesn't match the previous string
*/
smartBackspace?: boolean;
/**
* shuffle the strings
*/
shuffle?: boolean;
/**
* time before backspacing in milliseconds
*/
backDelay?: number;
/**
* Fade out instead of backspace
*/
fadeOut?: boolean;
/**
* css class for fade animation
*/
fadeOutClass?: string;
/**
* Fade out delay in milliseconds
*/
fadeOutDelay?: number;
/**
* loop strings
*/
loop?: boolean;
/**
* amount of loops
*/
loopCount?: number;
/**
* show cursor
*/
showCursor?: boolean;
/**
* character for cursor
*/
cursorChar?: string;
/**
* insert CSS for cursor and fadeOut into HTML
*/
autoInsertCss?: boolean;
/**
* attribute for typing Ex: input placeholder, value, or just HTML text
*/
attr?: string;
/**
* bind to focus and blur if el is text input
*/
bindInputFocusEvents?: boolean;
/**
* 'html' or 'null' for plaintext
*/
contentType?: string;
/**
* Before it begins typing the first string
*/
onBegin?(self: Typed): void;
/**
* All typing is complete
*/
onComplete?(self: Typed): void;
/**
* Before each string is typed
*/
preStringTyped?(arrayPos: number, self: Typed): void;
/**
* After each string is typed
*/
onStringTyped?(arrayPos: number, self: Typed): void;
/**
* During looping, after last string is typed
*/
onLastStringBackspaced?(self: Typed): void;
/**
* Typing has been stopped
*/
onTypingPaused?(arrayPos: number, self: Typed): void;
/**
* Typing has been started after being stopped
*/
onTypingResumed?(arrayPos: number, self: Typed): void;
/**
* After reset
*/
onReset?(self: Typed): void;
/**
* After stop
*/
onStop?(arrayPos: number, self: Typed): void;
/**
* After start
*/
onStart?(arrayPos: number, self: Typed): void;
/**
* After destroy
*/
onDestroy?(self: Typed): void;
}
export default class Typed {
constructor(elementId: any, options: TypedOptions);
/**
* Toggle start() and stop() of the Typed instance
* @public
*/
public toggle(): void;
/**
* Stop typing / backspacing and enable cursor blinking
* @public
*/
public stop(): void;
/**
* Start typing / backspacing after being stopped
* @public
*/
public start(): void;
/**
* Destroy this instance of Typed
* @public
*/
public destroy(): void;
/**
* Reset Typed and optionally restarts
* @param {boolean} restart
* @public
*/
public reset(restart?: boolean): void;
cursor: HTMLSpanElement;
strPos: number;
arrayPos: number;
curLoop: number;
/**
* Begins the typing animation
* @private
*/
private begin;
typingComplete: boolean;
timeout: any;
/**
* Called for each character typed
* @param {string} curString the current string in the strings array
* @param {number} curStrPos the current position in the curString
* @private
*/
private typewrite;
temporaryPause: boolean;
/**
* Continue to the next string & begin typing
* @param {string} curString the current string in the strings array
* @param {number} curStrPos the current position in the curString
* @private
*/
private keepTyping;
/**
* We're done typing the current string
* @param {string} curString the current string in the strings array
* @param {number} curStrPos the current position in the curString
* @private
*/
private doneTyping;
/**
* Backspaces 1 character at a time
* @param {string} curString the current string in the strings array
* @param {number} curStrPos the current position in the curString
* @private
*/
private backspace;
stopNum: number;
/**
* Full animation is complete
* @private
*/
private complete;
/**
* Has the typing been stopped
* @param {string} curString the current string in the strings array
* @param {number} curStrPos the current position in the curString
* @param {boolean} isTyping
* @private
*/
private setPauseStatus;
/**
* Toggle the blinking cursor
* @param {boolean} isBlinking
* @private
*/
private toggleBlinking;
cursorBlinking: any;
/**
* Speed in MS to type
* @param {number} speed
* @private
*/
private humanizer;
/**
* Shuffle the sequence of the strings array
* @private
*/
private shuffleStringsIfNeeded;
sequence: any;
/**
* Adds a CSS class to fade out current string
* @private
*/
private initFadeOut;
/**
* Replaces current text in the HTML element
* depending on element type
* @param {string} str
* @private
*/
private replaceText;
/**
* If using input elements, bind focus in order to
* start and stop the animation
* @private
*/
private bindFocusEvents;
/**
* On init, insert the cursor element
* @private
*/
private insertCursor;
}
}