File tree 2 files changed +25
-13
lines changed
2 files changed +25
-13
lines changed Original file line number Diff line number Diff line change 36
36
] ,
37
37
38
38
// Duration before the text starts writing
39
- addDelay : 0 ,
39
+ addDelay : 1000 ,
40
40
41
41
// How fast each letter is added
42
42
addSpeed : 10 ,
Original file line number Diff line number Diff line change 1
1
class TextWriter {
2
2
3
- constructor ( config ) {
3
+ constructor ( {
4
+ element = undefined ,
5
+ text = [ 'Hello World' ] ,
6
+ addDelay = 1000 ,
7
+ addSpeed = 100 ,
8
+ speedVariance = 0 ,
9
+ deleteDelay = 1000 ,
10
+ deleteSpeed = 50 ,
11
+ loopInfinitely = true ,
12
+ // endPoint = 'end',
13
+ cursorCharacter = '|'
14
+ } ) {
4
15
5
16
// Private
6
17
this . _textIndexFirst = 0 ;
7
18
this . _textIndexCurr = 0 ;
8
- this . _textIndexLast = config . text . length - 1 ;
19
+ this . _textIndexLast = text . length - 1 ;
9
20
10
21
// Public
11
- this . element = config . element ;
12
- this . addDelay = config . addDelay || 1000 ;
13
- this . addSpeed = config . addSpeed || 100 ;
14
- this . speedVariance = config . speedVariance || 0 ;
15
- this . deleteDelay = config . deleteDelay || 1000 ;
16
- this . deleteSpeed = config . deleteSpeed || 50 ;
17
- this . loopInfinitely = config . loopInfinitely || true ;
18
- this . endPoint = config . endPoint || 'end' ;
19
- this . cursorCharacter = config . cursorCharacter || '|' ;
20
- this . text = config . text ;
22
+ this . element = element ;
23
+ this . text = text ;
24
+
25
+ this . addDelay = addDelay ;
26
+ this . addSpeed = addSpeed ;
27
+ this . speedVariance = speedVariance ;
28
+ this . deleteDelay = deleteDelay ;
29
+ this . deleteSpeed = deleteSpeed ;
30
+ this . loopInfinitely = loopInfinitely ;
31
+ // this.endPoint = endPoint;
32
+ this . cursorCharacter = cursorCharacter ;
21
33
22
34
// Require a DOM node type
23
35
if ( ! this . element ) {
You can’t perform that action at this time.
0 commit comments