Skip to content

Commit fe0d9f3

Browse files
Simon PetrySimon Petry
Simon Petry
authored and
Simon Petry
committedJun 3, 2016
Destructured the default configuration options
1 parent 26a2ee4 commit fe0d9f3

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed
 

‎demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
],
3737

3838
// Duration before the text starts writing
39-
addDelay : 0,
39+
addDelay : 1000,
4040

4141
// How fast each letter is added
4242
addSpeed : 10,

‎prompt-writer.js

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
class TextWriter {
22

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+
}) {
415

516
// Private
617
this._textIndexFirst = 0;
718
this._textIndexCurr = 0;
8-
this._textIndexLast = config.text.length - 1;
19+
this._textIndexLast = text.length - 1;
920

1021
// 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;
2133

2234
// Require a DOM node type
2335
if ( !this.element ) {

0 commit comments

Comments
 (0)