typed.js 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +4 -0
- package/README.md +58 -47
- package/assets/demos.js +51 -14
- package/bower.json +3 -8
- package/docs/API.md +9 -0
- package/docs/index.html +41 -1
- package/gulpfile.js +41 -36
- package/index.d.ts +1 -1
- package/index.html +1 -0
- package/lib/typed.js +9 -3
- package/lib/typed.min.js +2 -2
- package/lib/typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/defaults.js +12 -1
- package/src/html-parser.js +0 -1
- package/src/initializer.js +17 -7
- package/src/typed.js +19 -7
- package/webpack.config.js +1 -3
- package/yarn.lock +0 -7735
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -6,47 +6,48 @@
|
|
|
6
6
|
|
|
7
7
|
<img src="https://raw.githubusercontent.com/mattboldt/typed.js/master/logo-cropped.png" width="450px" title="Typed.js" />
|
|
8
8
|
|
|
9
|
-
### [Live Demo](http://www.mattboldt.com/demos/typed-js/) | [View All Demos](http://
|
|
9
|
+
### [Live Demo](http://www.mattboldt.com/demos/typed-js/) | [View All Demos](http://mattboldt.github.io/typed.js/) | [View Full Docs](http://mattboldt.github.io/typed.js/docs) | [mattboldt.com](http://www.mattboldt.com)
|
|
10
10
|
|
|
11
11
|
Typed.js is a library that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
Installation
|
|
16
|
-
------------
|
|
15
|
+
## Installation
|
|
17
16
|
|
|
18
17
|
#### Choose One
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
```
|
|
21
20
|
npm install typed.js
|
|
22
21
|
yarn add typed.js
|
|
23
22
|
bower install typed.js
|
|
24
|
-
|
|
23
|
+
```
|
|
25
24
|
|
|
26
25
|
#### CDN
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.
|
|
30
|
-
|
|
27
|
+
```html
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11"></script>
|
|
29
|
+
```
|
|
31
30
|
|
|
32
31
|
#### Setup
|
|
33
32
|
|
|
34
33
|
This is really all you need to get going.
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
```javascript
|
|
37
36
|
// Can also be included with a regular script tag
|
|
38
37
|
import Typed from 'typed.js';
|
|
39
38
|
|
|
40
39
|
var options = {
|
|
41
|
-
strings: [
|
|
40
|
+
strings: ['<i>First</i> sentence.', '& a second sentence.'],
|
|
42
41
|
typeSpeed: 40
|
|
43
|
-
}
|
|
42
|
+
};
|
|
44
43
|
|
|
45
|
-
var typed = new Typed(
|
|
46
|
-
|
|
44
|
+
var typed = new Typed('.element', options);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Wonderful sites that have used (or are using) Typed.js
|
|
48
|
+
|
|
49
|
+
https://github.com/features/package-registry
|
|
47
50
|
|
|
48
|
-
Wonderful sites that have used (or are using) Typed.js
|
|
49
|
-
---
|
|
50
51
|
https://slack.com/
|
|
51
52
|
|
|
52
53
|
https://envato.com/
|
|
@@ -74,68 +75,70 @@ https://www.powerauth.com/
|
|
|
74
75
|
---
|
|
75
76
|
|
|
76
77
|
### Strings from static HTML (SEO Friendly)
|
|
78
|
+
|
|
77
79
|
Rather than using the `strings` array to insert strings, you can place an HTML `div` on the page and read from it.
|
|
78
80
|
This allows bots and search engines, as well as users with JavaScript disabled, to see your text on the page.
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
```javascript
|
|
81
83
|
<script>
|
|
82
84
|
var typed = new Typed('#typed', {
|
|
83
85
|
stringsElement: '#typed-strings'
|
|
84
86
|
});
|
|
85
87
|
</script>
|
|
86
|
-
|
|
88
|
+
```
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
```html
|
|
89
91
|
<div id="typed-strings">
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
<p>Typed.js is a <strong>JavaScript</strong> library.</p>
|
|
93
|
+
<p>It <em>types</em> out sentences.</p>
|
|
92
94
|
</div>
|
|
93
95
|
<span id="typed"></span>
|
|
94
|
-
|
|
96
|
+
```
|
|
95
97
|
|
|
96
98
|
### Type Pausing
|
|
97
99
|
|
|
98
100
|
You can pause in the middle of a string for a given amount of time by including an escape character.
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
var typed = new Typed(
|
|
102
|
+
```javascript
|
|
103
|
+
var typed = new Typed('.element', {
|
|
102
104
|
// Waits 1000ms after typing "First"
|
|
103
|
-
strings: [
|
|
105
|
+
strings: ['First ^1000 sentence.', 'Second sentence.']
|
|
104
106
|
});
|
|
105
|
-
|
|
107
|
+
```
|
|
106
108
|
|
|
107
109
|
### Smart Backspacing
|
|
108
110
|
|
|
109
111
|
In the following example, this would only backspace the words after "This is a"
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
var typed = new Typed(
|
|
113
|
-
strings: [
|
|
113
|
+
```javascript
|
|
114
|
+
var typed = new Typed('.element', {
|
|
115
|
+
strings: ['This is a JavaScript library', 'This is an ES6 module'],
|
|
114
116
|
smartBackspace: true // Default value
|
|
115
117
|
});
|
|
116
|
-
|
|
118
|
+
```
|
|
117
119
|
|
|
118
120
|
### Bulk Typing
|
|
119
121
|
|
|
120
|
-
The following example would emulate how a terminal acts when typing a command and seeing its result.
|
|
122
|
+
The following example would emulate how a terminal acts when typing a command and seeing its result.
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
var typed = new Typed(
|
|
124
|
-
strings: [
|
|
125
|
-
"git push --force ^1000\n `pushed to origin with option force`"
|
|
126
|
-
]
|
|
124
|
+
```javascript
|
|
125
|
+
var typed = new Typed('.element', {
|
|
126
|
+
strings: ['git push --force ^1000\n `pushed to origin with option force`']
|
|
127
127
|
});
|
|
128
|
-
|
|
128
|
+
```
|
|
129
129
|
|
|
130
130
|
### CSS
|
|
131
131
|
|
|
132
132
|
CSS animations are built upon initialzation in JavaScript. But, you can customize them at your will! These classes are:
|
|
133
|
+
|
|
133
134
|
```css
|
|
134
135
|
/* Cursor */
|
|
135
|
-
.typed-cursor {
|
|
136
|
+
.typed-cursor {
|
|
137
|
+
}
|
|
136
138
|
|
|
137
139
|
/* If fade out option is set */
|
|
138
|
-
.typed-fade-out {
|
|
140
|
+
.typed-fade-out {
|
|
141
|
+
}
|
|
139
142
|
```
|
|
140
143
|
|
|
141
144
|
### Use with ReactJS
|
|
@@ -150,16 +153,20 @@ Check out the Vue.js component: https://github.com/Orlandster/vue-typed-js
|
|
|
150
153
|
|
|
151
154
|
Check out the WebComponent: https://github.com/Orlandster/wc-typed-js
|
|
152
155
|
|
|
153
|
-
Customization
|
|
154
|
-
----
|
|
156
|
+
## Customization
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
var typed = new Typed(
|
|
158
|
+
```javascript
|
|
159
|
+
var typed = new Typed('.element', {
|
|
158
160
|
/**
|
|
159
161
|
* @property {array} strings strings to be typed
|
|
160
162
|
* @property {string} stringsElement ID of element containing string children
|
|
161
163
|
*/
|
|
162
|
-
strings: [
|
|
164
|
+
strings: [
|
|
165
|
+
'These are the default values...',
|
|
166
|
+
'You know what you should do?',
|
|
167
|
+
'Use your own!',
|
|
168
|
+
'Have a great day!'
|
|
169
|
+
],
|
|
163
170
|
stringsElement: null,
|
|
164
171
|
|
|
165
172
|
/**
|
|
@@ -233,6 +240,12 @@ var typed = new Typed(".element", {
|
|
|
233
240
|
*/
|
|
234
241
|
contentType: 'html',
|
|
235
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Before it begins typing
|
|
245
|
+
* @param {Typed} self
|
|
246
|
+
*/
|
|
247
|
+
onBegin: (self) => {},
|
|
248
|
+
|
|
236
249
|
/**
|
|
237
250
|
* All typing is complete
|
|
238
251
|
* @param {Typed} self
|
|
@@ -299,15 +312,13 @@ var typed = new Typed(".element", {
|
|
|
299
312
|
*/
|
|
300
313
|
onDestroy: (self) => {}
|
|
301
314
|
});
|
|
302
|
-
|
|
303
|
-
|
|
315
|
+
```
|
|
304
316
|
|
|
305
317
|
## Contributing
|
|
306
318
|
|
|
307
319
|
### [View Contribution Guidelines](./.github/CONTRIBUTING.md)
|
|
308
320
|
|
|
309
|
-
end
|
|
310
|
-
---
|
|
321
|
+
## end
|
|
311
322
|
|
|
312
323
|
Thanks for checking this out. If you have any questions, I'll be on [Twitter](http://www.twitter.com/atmattb).
|
|
313
324
|
|
package/assets/demos.js
CHANGED
|
@@ -6,16 +6,39 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
6
6
|
startDelay: 1000,
|
|
7
7
|
loop: false,
|
|
8
8
|
loopCount: Infinity,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
onBegin: function(self) {
|
|
10
|
+
prettyLog('onBegin ' + self);
|
|
11
|
+
},
|
|
12
|
+
onComplete: function(self) {
|
|
13
|
+
prettyLog('onComplete ' + self);
|
|
14
|
+
},
|
|
15
|
+
preStringTyped: function(pos, self) {
|
|
16
|
+
prettyLog('preStringTyped ' + pos + ' ' + self);
|
|
17
|
+
},
|
|
18
|
+
onStringTyped: function(pos, self) {
|
|
19
|
+
prettyLog('onStringTyped ' + pos + ' ' + self);
|
|
20
|
+
},
|
|
21
|
+
onLastStringBackspaced: function(self) {
|
|
22
|
+
prettyLog('onLastStringBackspaced ' + self);
|
|
23
|
+
},
|
|
24
|
+
onTypingPaused: function(pos, self) {
|
|
25
|
+
prettyLog('onTypingPaused ' + pos + ' ' + self);
|
|
26
|
+
},
|
|
27
|
+
onTypingResumed: function(pos, self) {
|
|
28
|
+
prettyLog('onTypingResumed ' + pos + ' ' + self);
|
|
29
|
+
},
|
|
30
|
+
onReset: function(self) {
|
|
31
|
+
prettyLog('onReset ' + self);
|
|
32
|
+
},
|
|
33
|
+
onStop: function(pos, self) {
|
|
34
|
+
prettyLog('onStop ' + pos + ' ' + self);
|
|
35
|
+
},
|
|
36
|
+
onStart: function(pos, self) {
|
|
37
|
+
prettyLog('onStart ' + pos + ' ' + self);
|
|
38
|
+
},
|
|
39
|
+
onDestroy: function(self) {
|
|
40
|
+
prettyLog('onDestroy ' + self);
|
|
41
|
+
}
|
|
19
42
|
});
|
|
20
43
|
|
|
21
44
|
document.querySelector('.toggle').addEventListener('click', function() {
|
|
@@ -38,7 +61,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
38
61
|
});
|
|
39
62
|
|
|
40
63
|
var typed2 = new Typed('#typed2', {
|
|
41
|
-
strings: [
|
|
64
|
+
strings: [
|
|
65
|
+
'Some <i>strings</i> with',
|
|
66
|
+
'Some <strong>HTML</strong>',
|
|
67
|
+
'Chars × ©'
|
|
68
|
+
],
|
|
42
69
|
typeSpeed: 0,
|
|
43
70
|
backSpeed: 0,
|
|
44
71
|
fadeOut: true,
|
|
@@ -49,7 +76,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
49
76
|
});
|
|
50
77
|
|
|
51
78
|
new Typed('#typed3', {
|
|
52
|
-
strings: [
|
|
79
|
+
strings: [
|
|
80
|
+
'My strings are: <i>strings</i> with',
|
|
81
|
+
'My strings are: <strong>HTML</strong>',
|
|
82
|
+
'My strings are: Chars × ©'
|
|
83
|
+
],
|
|
53
84
|
typeSpeed: 0,
|
|
54
85
|
backSpeed: 0,
|
|
55
86
|
smartBackspace: true,
|
|
@@ -66,7 +97,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
66
97
|
});
|
|
67
98
|
|
|
68
99
|
new Typed('#typed5', {
|
|
69
|
-
strings: [
|
|
100
|
+
strings: [
|
|
101
|
+
'1 Some <i>strings</i> with',
|
|
102
|
+
'2 Some <strong>HTML</strong>',
|
|
103
|
+
'3 Chars × ©'
|
|
104
|
+
],
|
|
70
105
|
typeSpeed: 0,
|
|
71
106
|
backSpeed: 0,
|
|
72
107
|
shuffle: true,
|
|
@@ -76,7 +111,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
76
111
|
});
|
|
77
112
|
|
|
78
113
|
new Typed('#typed6', {
|
|
79
|
-
strings: [
|
|
114
|
+
strings: [
|
|
115
|
+
'npm install^1000\n`installing components...` ^1000\n`Fetching from source...`'
|
|
116
|
+
],
|
|
80
117
|
typeSpeed: 40,
|
|
81
118
|
backSpeed: 0,
|
|
82
119
|
loop: true
|
package/bower.json
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typed.js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"homepage": "https://github.com/mattboldt/typed.js",
|
|
5
|
-
"authors": [
|
|
6
|
-
"Matt Boldt <me@mattboldt.com>"
|
|
7
|
-
],
|
|
5
|
+
"authors": ["Matt Boldt <me@mattboldt.com>"],
|
|
8
6
|
"description": "A JavaScript Typing Animation Library",
|
|
9
7
|
"main": "lib/typed.js",
|
|
10
|
-
"keywords": [
|
|
11
|
-
"typed",
|
|
12
|
-
"animation"
|
|
13
|
-
],
|
|
8
|
+
"keywords": ["typed", "animation"],
|
|
14
9
|
"ignore": [],
|
|
15
10
|
"license": "MIT"
|
|
16
11
|
}
|
package/docs/API.md
CHANGED
|
@@ -91,6 +91,15 @@ Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
|
|
|
91
91
|
|
|
92
92
|
- `contentType` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 'html' or 'null' for plaintext
|
|
93
93
|
|
|
94
|
+
### onBegin
|
|
95
|
+
|
|
96
|
+
Before it begins typing
|
|
97
|
+
|
|
98
|
+
**Parameters**
|
|
99
|
+
|
|
100
|
+
- `self` **[Typed](#typed)**
|
|
101
|
+
|
|
102
|
+
|
|
94
103
|
### onComplete
|
|
95
104
|
|
|
96
105
|
All typing is complete
|
package/docs/index.html
CHANGED
|
@@ -113,7 +113,13 @@
|
|
|
113
113
|
class='regular pre-open'>
|
|
114
114
|
.contentType
|
|
115
115
|
</a></li>
|
|
116
|
-
|
|
116
|
+
|
|
117
|
+
<li><a
|
|
118
|
+
href='#defaults.onBegin'
|
|
119
|
+
class='regular pre-open'>
|
|
120
|
+
.onBegin
|
|
121
|
+
</a></li>
|
|
122
|
+
|
|
117
123
|
<li><a
|
|
118
124
|
href='#defaults.onComplete'
|
|
119
125
|
class='regular pre-open'>
|
|
@@ -1083,6 +1089,40 @@ Ex: input placeholder, value, or just HTML text
|
|
|
1083
1089
|
</div>
|
|
1084
1090
|
</div>
|
|
1085
1091
|
|
|
1092
|
+
<div class='border-bottom' id='defaults.onBegin'>
|
|
1093
|
+
<div class="clearfix small pointer toggle-sibling">
|
|
1094
|
+
<div class="py1 contain">
|
|
1095
|
+
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
1096
|
+
<span class='code strong strong truncate'>onBegin(self)</span>
|
|
1097
|
+
</div>
|
|
1098
|
+
</div>
|
|
1099
|
+
<div class="clearfix display-none toggle-target">
|
|
1100
|
+
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
<p>Before it begins typing</p>
|
|
1105
|
+
|
|
1106
|
+
<div class='pre p1 fill-light mt0'>onBegin(self: <a href="#typed">Typed</a>)</div>
|
|
1107
|
+
|
|
1108
|
+
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
1109
|
+
<div class='prose'>
|
|
1110
|
+
|
|
1111
|
+
<div class='space-bottom0'>
|
|
1112
|
+
<div>
|
|
1113
|
+
<span class='code bold'>self</span> <code class='quiet'>(<a href="#typed">Typed</a>)</code>
|
|
1114
|
+
|
|
1115
|
+
</div>
|
|
1116
|
+
|
|
1117
|
+
</div>
|
|
1118
|
+
|
|
1119
|
+
</div>
|
|
1120
|
+
|
|
1121
|
+
</section>
|
|
1122
|
+
|
|
1123
|
+
</div>
|
|
1124
|
+
</div>
|
|
1125
|
+
|
|
1086
1126
|
<div class='border-bottom' id='defaults.onComplete'>
|
|
1087
1127
|
<div class="clearfix small pointer toggle-sibling">
|
|
1088
1128
|
<div class="py1 contain">
|
package/gulpfile.js
CHANGED
|
@@ -10,27 +10,33 @@ const eslint = require('gulp-eslint');
|
|
|
10
10
|
const server = require('gulp-express');
|
|
11
11
|
|
|
12
12
|
gulp.task('lint', () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
return (
|
|
14
|
+
gulp
|
|
15
|
+
.src('src/*.js')
|
|
16
|
+
// default: use local linting config
|
|
17
|
+
.pipe(eslint())
|
|
18
|
+
// format ESLint results and print them to the console
|
|
19
|
+
.pipe(eslint.format())
|
|
20
|
+
.pipe(eslint.failAfterError())
|
|
21
|
+
);
|
|
19
22
|
});
|
|
20
23
|
|
|
21
24
|
gulp.task('build', () => {
|
|
22
|
-
return gulp
|
|
25
|
+
return gulp
|
|
26
|
+
.src('src/*.js')
|
|
23
27
|
.pipe(webpack(require('./webpack.config.js')))
|
|
24
28
|
.pipe(gulp.dest('./lib'))
|
|
25
29
|
.pipe(sourcemaps.init({ loadMaps: true }))
|
|
26
|
-
.pipe(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
.pipe(
|
|
31
|
+
uglify({
|
|
32
|
+
preserveComments: 'license',
|
|
33
|
+
compress: {
|
|
34
|
+
/*eslint-disable */
|
|
35
|
+
negate_iife: false
|
|
36
|
+
/*eslint-enable */
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
)
|
|
34
40
|
.pipe(rename('typed.min.js'))
|
|
35
41
|
.pipe(sourcemaps.write('./'))
|
|
36
42
|
.pipe(gulp.dest('lib/'))
|
|
@@ -38,21 +44,27 @@ gulp.task('build', () => {
|
|
|
38
44
|
});
|
|
39
45
|
|
|
40
46
|
gulp.task('md-docs', () => {
|
|
41
|
-
return gulp
|
|
47
|
+
return gulp
|
|
48
|
+
.src('./src/*.js')
|
|
42
49
|
.pipe(gulpDocumentation('md'))
|
|
43
50
|
.pipe(gulp.dest('docs'));
|
|
44
51
|
});
|
|
45
52
|
|
|
46
53
|
gulp.task('html-docs', () => {
|
|
47
|
-
return gulp
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
return gulp
|
|
55
|
+
.src('./src/*.js')
|
|
56
|
+
.pipe(
|
|
57
|
+
gulpDocumentation('html'),
|
|
58
|
+
{},
|
|
59
|
+
{
|
|
60
|
+
name: 'Typed.js Docs',
|
|
61
|
+
version: '2.0.11'
|
|
62
|
+
}
|
|
63
|
+
)
|
|
52
64
|
.pipe(gulp.dest('docs'));
|
|
53
65
|
});
|
|
54
66
|
|
|
55
|
-
gulp.task('server', function
|
|
67
|
+
gulp.task('server', function() {
|
|
56
68
|
// Start the server at the beginning of the task
|
|
57
69
|
server.run(['app.js']);
|
|
58
70
|
// Restart the server when file changes
|
|
@@ -61,21 +73,18 @@ gulp.task('server', function () {
|
|
|
61
73
|
//gulp.watch(['{.tmp,app}/styles/**/*.css'], ['styles:css', server.notify]);
|
|
62
74
|
//Event object won't pass down to gulp.watch's callback if there's more than one of them.
|
|
63
75
|
//So the correct way to use server.notify is as following:
|
|
64
|
-
gulp.watch(['{.tmp,docs}/styles/**/*.css'], function(event){
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
gulp.watch(['{.tmp,docs}/styles/**/*.css'], function(event) {
|
|
77
|
+
gulp.run('styles:css');
|
|
78
|
+
server.notify(event);
|
|
79
|
+
//pipe support is added for server.notify since v0.1.5,
|
|
80
|
+
//see https://github.com/gimm/gulp-express#servernotifyevent
|
|
69
81
|
});
|
|
70
82
|
|
|
71
83
|
gulp.watch(['docs/scripts/**/*.js'], ['jshint']);
|
|
72
84
|
gulp.watch(['docs/images/**/*'], server.notify);
|
|
73
85
|
});
|
|
74
86
|
|
|
75
|
-
gulp.task('serve', [
|
|
76
|
-
'watch',
|
|
77
|
-
'server'
|
|
78
|
-
]);
|
|
87
|
+
gulp.task('serve', ['watch', 'server']);
|
|
79
88
|
|
|
80
89
|
// Watch Task
|
|
81
90
|
gulp.task('watch', () => {
|
|
@@ -83,8 +92,4 @@ gulp.task('watch', () => {
|
|
|
83
92
|
gulp.watch('src/*.js', ['md-docs', 'html-docs', 'default']);
|
|
84
93
|
});
|
|
85
94
|
|
|
86
|
-
gulp.task('default', [
|
|
87
|
-
'lint',
|
|
88
|
-
'build',
|
|
89
|
-
]);
|
|
90
|
-
|
|
95
|
+
gulp.task('default', ['lint', 'build']);
|
package/index.d.ts
CHANGED
package/index.html
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
backDelay: 500,
|
|
52
52
|
startDelay: 1000,
|
|
53
53
|
loop: false,
|
|
54
|
+
onBegin: function(self) { prettyLog('onBegin ' + self) },
|
|
54
55
|
onComplete: function(self) { prettyLog('onCmplete ' + self) },
|
|
55
56
|
preStringTyped: function(pos, self) { prettyLog('preStringTyped ' + pos + ' ' + self); },
|
|
56
57
|
onStringTyped: function(pos, self) { prettyLog('onStringTyped ' + pos + ' ' + self) },
|
package/lib/typed.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* typed.js - A JavaScript Typing Animation Library
|
|
4
4
|
* Author: Matt Boldt <me@mattboldt.com>
|
|
5
|
-
* Version: v2.0.
|
|
5
|
+
* Version: v2.0.11
|
|
6
6
|
* Url: https://github.com/mattboldt/typed.js
|
|
7
7
|
* License(s): MIT
|
|
8
8
|
*
|
|
@@ -183,6 +183,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
183
183
|
value: function begin() {
|
|
184
184
|
var _this = this;
|
|
185
185
|
|
|
186
|
+
this.options.onBegin(this);
|
|
186
187
|
this.typingComplete = false;
|
|
187
188
|
this.shuffleStringsIfNeeded(this);
|
|
188
189
|
this.insertCursor();
|
|
@@ -307,7 +308,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
|
-
* We're done typing
|
|
311
|
+
* We're done typing the current string
|
|
311
312
|
* @param {string} curString the current string in the strings array
|
|
312
313
|
* @param {number} curStrPos the current position in the curString
|
|
313
314
|
* @private
|
|
@@ -872,6 +873,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
872
873
|
*/
|
|
873
874
|
contentType: 'html',
|
|
874
875
|
|
|
876
|
+
/**
|
|
877
|
+
* Before it begins typing
|
|
878
|
+
* @param {Typed} self
|
|
879
|
+
*/
|
|
880
|
+
onBegin: function onBegin(self) {},
|
|
881
|
+
|
|
875
882
|
/**
|
|
876
883
|
* All typing is complete
|
|
877
884
|
* @param {Typed} self
|
|
@@ -946,7 +953,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
946
953
|
/* 3 */
|
|
947
954
|
/***/ (function(module, exports) {
|
|
948
955
|
|
|
949
|
-
|
|
950
956
|
/**
|
|
951
957
|
* TODO: These methods can probably be combined somehow
|
|
952
958
|
* Parse HTML tags & HTML Characters
|
package/lib/typed.min.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
*
|
|
3
3
|
* typed.js - A JavaScript Typing Animation Library
|
|
4
4
|
* Author: Matt Boldt <me@mattboldt.com>
|
|
5
|
-
* Version: v2.0.
|
|
5
|
+
* Version: v2.0.11
|
|
6
6
|
* Url: https://github.com/mattboldt/typed.js
|
|
7
7
|
* License(s): MIT
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Typed=e():t.Typed=e()})(this,function(){return function(t){function e(n){if(s[n])return s[n].exports;var i=s[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),r=s(1),o=s(3),a=function(){function t(e,s){n(this,t),r.initializer.load(this,s,e),this.begin()}return i(t,[{key:"toggle",value:function(){this.pause.status?this.start():this.stop()}},{key:"stop",value:function(){this.typingComplete||this.pause.status||(this.toggleBlinking(!0),this.pause.status=!0,this.options.onStop(this.arrayPos,this))}},{key:"start",value:function(){this.typingComplete||this.pause.status&&(this.pause.status=!1,this.pause.typewrite?this.typewrite(this.pause.curString,this.pause.curStrPos):this.backspace(this.pause.curString,this.pause.curStrPos),this.options.onStart(this.arrayPos,this))}},{key:"destroy",value:function(){this.reset(!1),this.options.onDestroy(this)}},{key:"reset",value:function(){var t=arguments.length<=0||void 0===arguments[0]||arguments[0];clearInterval(this.timeout),this.replaceText(""),this.cursor&&this.cursor.parentNode&&(this.cursor.parentNode.removeChild(this.cursor),this.cursor=null),this.strPos=0,this.arrayPos=0,this.curLoop=0,t&&(this.insertCursor(),this.options.onReset(this),this.begin())}},{key:"begin",value:function(){var t=this;this.typingComplete=!1,this.shuffleStringsIfNeeded(this),this.insertCursor(),this.bindInputFocusEvents&&this.bindFocusEvents(),this.timeout=setTimeout(function(){t.currentElContent&&0!==t.currentElContent.length?t.backspace(t.currentElContent,t.currentElContent.length):t.typewrite(t.strings[t.sequence[t.arrayPos]],t.strPos)},this.startDelay)}},{key:"typewrite",value:function(t,e){var s=this;this.fadeOut&&this.el.classList.contains(this.fadeOutClass)&&(this.el.classList.remove(this.fadeOutClass),this.cursor&&this.cursor.classList.remove(this.fadeOutClass));var n=this.humanizer(this.typeSpeed),i=1;return this.pause.status===!0?void this.setPauseStatus(t,e,!0):void(this.timeout=setTimeout(function(){e=o.htmlParser.typeHtmlChars(t,e,s);var n=0,r=t.substr(e);if("^"===r.charAt(0)&&/^\^\d+/.test(r)){var a=1;r=/\d+/.exec(r)[0],a+=r.length,n=parseInt(r),s.temporaryPause=!0,s.options.onTypingPaused(s.arrayPos,s),t=t.substring(0,e)+t.substring(e+a),s.toggleBlinking(!0)}if("`"===r.charAt(0)){for(;"`"!==t.substr(e+i).charAt(0)&&(i++,!(e+i>t.length)););var u=t.substring(0,e),l=t.substring(u.length+1,e+i),c=t.substring(e+i+1);t=u+l+c,i--}s.timeout=setTimeout(function(){s.toggleBlinking(!1),e>=t.length?s.doneTyping(t,e):s.keepTyping(t,e,i),s.temporaryPause&&(s.temporaryPause=!1,s.options.onTypingResumed(s.arrayPos,s))},n)},n))}},{key:"keepTyping",value:function(t,e,s){0===e&&(this.toggleBlinking(!1),this.options.preStringTyped(this.arrayPos,this)),e+=s;var n=t.substr(0,e);this.replaceText(n),this.typewrite(t,e)}},{key:"doneTyping",value:function(t,e){var s=this;this.options.onStringTyped(this.arrayPos,this),this.toggleBlinking(!0),this.arrayPos===this.strings.length-1&&(this.complete(),this.loop===!1||this.curLoop===this.loopCount)||(this.timeout=setTimeout(function(){s.backspace(t,e)},this.backDelay))}},{key:"backspace",value:function(t,e){var s=this;if(this.pause.status===!0)return void this.setPauseStatus(t,e,!0);if(this.fadeOut)return this.initFadeOut();this.toggleBlinking(!1);var n=this.humanizer(this.backSpeed);this.timeout=setTimeout(function(){e=o.htmlParser.backSpaceHtmlChars(t,e,s);var n=t.substr(0,e);if(s.replaceText(n),s.smartBackspace){var i=s.strings[s.arrayPos+1];i&&n===i.substr(0,e)?s.stopNum=e:s.stopNum=0}e>s.stopNum?(e--,s.backspace(t,e)):e<=s.stopNum&&(s.arrayPos++,s.arrayPos===s.strings.length?(s.arrayPos=0,s.options.onLastStringBackspaced(),s.shuffleStringsIfNeeded(),s.begin()):s.typewrite(s.strings[s.sequence[s.arrayPos]],e))},n)}},{key:"complete",value:function(){this.options.onComplete(this),this.loop?this.curLoop++:this.typingComplete=!0}},{key:"setPauseStatus",value:function(t,e,s){this.pause.typewrite=s,this.pause.curString=t,this.pause.curStrPos=e}},{key:"toggleBlinking",value:function(t){this.cursor&&(this.pause.status||this.cursorBlinking!==t&&(this.cursorBlinking=t,t?this.cursor.classList.add("typed-cursor--blink"):this.cursor.classList.remove("typed-cursor--blink")))}},{key:"humanizer",value:function(t){return Math.round(Math.random()*t/2)+t}},{key:"shuffleStringsIfNeeded",value:function(){this.shuffle&&(this.sequence=this.sequence.sort(function(){return Math.random()-.5}))}},{key:"initFadeOut",value:function(){var t=this;return this.el.className+=" "+this.fadeOutClass,this.cursor&&(this.cursor.className+=" "+this.fadeOutClass),setTimeout(function(){t.arrayPos++,t.replaceText(""),t.strings.length>t.arrayPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],0):(t.typewrite(t.strings[0],0),t.arrayPos=0)},this.fadeOutDelay)}},{key:"replaceText",value:function(t){this.attr?this.el.setAttribute(this.attr,t):this.isInput?this.el.value=t:"html"===this.contentType?this.el.innerHTML=t:this.el.textContent=t}},{key:"bindFocusEvents",value:function(){var t=this;this.isInput&&(this.el.addEventListener("focus",function(e){t.stop()}),this.el.addEventListener("blur",function(e){t.el.value&&0!==t.el.value.length||t.start()}))}},{key:"insertCursor",value:function(){this.showCursor&&(this.cursor||(this.cursor=document.createElement("span"),this.cursor.className="typed-cursor",this.cursor.innerHTML=this.cursorChar,this.el.parentNode&&this.el.parentNode.insertBefore(this.cursor,this.el.nextSibling)))}}]),t}();e["default"]=a,t.exports=e["default"]},function(t,e,s){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},o=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),a=s(2),u=n(a),l=function(){function t(){i(this,t)}return o(t,[{key:"load",value:function(t,e,s){if("string"==typeof s?t.el=document.querySelector(s):t.el=s,t.options=r({},u["default"],e),t.isInput="input"===t.el.tagName.toLowerCase(),t.attr=t.options.attr,t.bindInputFocusEvents=t.options.bindInputFocusEvents,t.showCursor=!t.isInput&&t.options.showCursor,t.cursorChar=t.options.cursorChar,t.cursorBlinking=!0,t.elContent=t.attr?t.el.getAttribute(t.attr):t.el.textContent,t.contentType=t.options.contentType,t.typeSpeed=t.options.typeSpeed,t.startDelay=t.options.startDelay,t.backSpeed=t.options.backSpeed,t.smartBackspace=t.options.smartBackspace,t.backDelay=t.options.backDelay,t.fadeOut=t.options.fadeOut,t.fadeOutClass=t.options.fadeOutClass,t.fadeOutDelay=t.options.fadeOutDelay,t.isPaused=!1,t.strings=t.options.strings.map(function(t){return t.trim()}),"string"==typeof t.options.stringsElement?t.stringsElement=document.querySelector(t.options.stringsElement):t.stringsElement=t.options.stringsElement,t.stringsElement){t.strings=[],t.stringsElement.style.display="none";var n=Array.prototype.slice.apply(t.stringsElement.children),i=n.length;if(i)for(var o=0;o<i;o+=1){var a=n[o];t.strings.push(a.innerHTML.trim())}}t.strPos=0,t.arrayPos=0,t.stopNum=0,t.loop=t.options.loop,t.loopCount=t.options.loopCount,t.curLoop=0,t.shuffle=t.options.shuffle,t.sequence=[],t.pause={status:!1,typewrite:!0,curString:"",curStrPos:0},t.typingComplete=!1;for(var o in t.strings)t.sequence[o]=o;t.currentElContent=this.getCurrentElContent(t),t.autoInsertCss=t.options.autoInsertCss,this.appendAnimationCss(t)}},{key:"getCurrentElContent",value:function(t){var e="";return e=t.attr?t.el.getAttribute(t.attr):t.isInput?t.el.value:"html"===t.contentType?t.el.innerHTML:t.el.textContent}},{key:"appendAnimationCss",value:function(t){var e="data-typed-js-css";if(t.autoInsertCss&&(t.showCursor||t.fadeOut)&&!document.querySelector("["+e+"]")){var s=document.createElement("style");s.type="text/css",s.setAttribute(e,!0);var n="";t.showCursor&&(n+="\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n "),t.fadeOut&&(n+="\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n "),0!==s.length&&(s.innerHTML=n,document.body.appendChild(s))}}}]),t}();e["default"]=l;var c=new l;e.initializer=c},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s={strings:["These are the default values...","You know what you should do?","Use your own!","Have a great day!"],stringsElement:null,typeSpeed:0,startDelay:0,backSpeed:0,smartBackspace:!0,shuffle:!1,backDelay:700,fadeOut:!1,fadeOutClass:"typed-fade-out",fadeOutDelay:500,loop:!1,loopCount:1/0,showCursor:!0,cursorChar:"|",autoInsertCss:!0,attr:null,bindInputFocusEvents:!1,contentType:"html",onComplete:function(t){},preStringTyped:function(t,e){},onStringTyped:function(t,e){},onLastStringBackspaced:function(t){},onTypingPaused:function(t,e){},onTypingResumed:function(t,e){},onReset:function(t){},onStop:function(t,e){},onStart:function(t,e){},onDestroy:function(t){}};e["default"]=s,t.exports=e["default"]},function(t,e){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),i=function(){function t(){s(this,t)}return n(t,[{key:"typeHtmlChars",value:function(t,e,s){if("html"!==s.contentType)return e;var n=t.substr(e).charAt(0);if("<"===n||"&"===n){var i="";for(i="<"===n?">":";";t.substr(e+1).charAt(0)!==i&&(e++,!(e+1>t.length)););e++}return e}},{key:"backSpaceHtmlChars",value:function(t,e,s){if("html"!==s.contentType)return e;var n=t.substr(e).charAt(0);if(">"===n||";"===n){var i="";for(i=">"===n?"<":"&";t.substr(e-1).charAt(0)!==i&&(e--,!(e<0)););e--}return e}}]),t}();e["default"]=i;var r=new i;e.htmlParser=r}])});
|
|
10
|
+
(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Typed=e():t.Typed=e()})(this,function(){return function(t){function e(n){if(s[n])return s[n].exports;var i=s[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),r=s(1),o=s(3),a=function(){function t(e,s){n(this,t),r.initializer.load(this,s,e),this.begin()}return i(t,[{key:"toggle",value:function(){this.pause.status?this.start():this.stop()}},{key:"stop",value:function(){this.typingComplete||this.pause.status||(this.toggleBlinking(!0),this.pause.status=!0,this.options.onStop(this.arrayPos,this))}},{key:"start",value:function(){this.typingComplete||this.pause.status&&(this.pause.status=!1,this.pause.typewrite?this.typewrite(this.pause.curString,this.pause.curStrPos):this.backspace(this.pause.curString,this.pause.curStrPos),this.options.onStart(this.arrayPos,this))}},{key:"destroy",value:function(){this.reset(!1),this.options.onDestroy(this)}},{key:"reset",value:function(){var t=arguments.length<=0||void 0===arguments[0]||arguments[0];clearInterval(this.timeout),this.replaceText(""),this.cursor&&this.cursor.parentNode&&(this.cursor.parentNode.removeChild(this.cursor),this.cursor=null),this.strPos=0,this.arrayPos=0,this.curLoop=0,t&&(this.insertCursor(),this.options.onReset(this),this.begin())}},{key:"begin",value:function(){var t=this;this.options.onBegin(this),this.typingComplete=!1,this.shuffleStringsIfNeeded(this),this.insertCursor(),this.bindInputFocusEvents&&this.bindFocusEvents(),this.timeout=setTimeout(function(){t.currentElContent&&0!==t.currentElContent.length?t.backspace(t.currentElContent,t.currentElContent.length):t.typewrite(t.strings[t.sequence[t.arrayPos]],t.strPos)},this.startDelay)}},{key:"typewrite",value:function(t,e){var s=this;this.fadeOut&&this.el.classList.contains(this.fadeOutClass)&&(this.el.classList.remove(this.fadeOutClass),this.cursor&&this.cursor.classList.remove(this.fadeOutClass));var n=this.humanizer(this.typeSpeed),i=1;return this.pause.status===!0?void this.setPauseStatus(t,e,!0):void(this.timeout=setTimeout(function(){e=o.htmlParser.typeHtmlChars(t,e,s);var n=0,r=t.substr(e);if("^"===r.charAt(0)&&/^\^\d+/.test(r)){var a=1;r=/\d+/.exec(r)[0],a+=r.length,n=parseInt(r),s.temporaryPause=!0,s.options.onTypingPaused(s.arrayPos,s),t=t.substring(0,e)+t.substring(e+a),s.toggleBlinking(!0)}if("`"===r.charAt(0)){for(;"`"!==t.substr(e+i).charAt(0)&&(i++,!(e+i>t.length)););var u=t.substring(0,e),l=t.substring(u.length+1,e+i),c=t.substring(e+i+1);t=u+l+c,i--}s.timeout=setTimeout(function(){s.toggleBlinking(!1),e>=t.length?s.doneTyping(t,e):s.keepTyping(t,e,i),s.temporaryPause&&(s.temporaryPause=!1,s.options.onTypingResumed(s.arrayPos,s))},n)},n))}},{key:"keepTyping",value:function(t,e,s){0===e&&(this.toggleBlinking(!1),this.options.preStringTyped(this.arrayPos,this)),e+=s;var n=t.substr(0,e);this.replaceText(n),this.typewrite(t,e)}},{key:"doneTyping",value:function(t,e){var s=this;this.options.onStringTyped(this.arrayPos,this),this.toggleBlinking(!0),this.arrayPos===this.strings.length-1&&(this.complete(),this.loop===!1||this.curLoop===this.loopCount)||(this.timeout=setTimeout(function(){s.backspace(t,e)},this.backDelay))}},{key:"backspace",value:function(t,e){var s=this;if(this.pause.status===!0)return void this.setPauseStatus(t,e,!0);if(this.fadeOut)return this.initFadeOut();this.toggleBlinking(!1);var n=this.humanizer(this.backSpeed);this.timeout=setTimeout(function(){e=o.htmlParser.backSpaceHtmlChars(t,e,s);var n=t.substr(0,e);if(s.replaceText(n),s.smartBackspace){var i=s.strings[s.arrayPos+1];i&&n===i.substr(0,e)?s.stopNum=e:s.stopNum=0}e>s.stopNum?(e--,s.backspace(t,e)):e<=s.stopNum&&(s.arrayPos++,s.arrayPos===s.strings.length?(s.arrayPos=0,s.options.onLastStringBackspaced(),s.shuffleStringsIfNeeded(),s.begin()):s.typewrite(s.strings[s.sequence[s.arrayPos]],e))},n)}},{key:"complete",value:function(){this.options.onComplete(this),this.loop?this.curLoop++:this.typingComplete=!0}},{key:"setPauseStatus",value:function(t,e,s){this.pause.typewrite=s,this.pause.curString=t,this.pause.curStrPos=e}},{key:"toggleBlinking",value:function(t){this.cursor&&(this.pause.status||this.cursorBlinking!==t&&(this.cursorBlinking=t,t?this.cursor.classList.add("typed-cursor--blink"):this.cursor.classList.remove("typed-cursor--blink")))}},{key:"humanizer",value:function(t){return Math.round(Math.random()*t/2)+t}},{key:"shuffleStringsIfNeeded",value:function(){this.shuffle&&(this.sequence=this.sequence.sort(function(){return Math.random()-.5}))}},{key:"initFadeOut",value:function(){var t=this;return this.el.className+=" "+this.fadeOutClass,this.cursor&&(this.cursor.className+=" "+this.fadeOutClass),setTimeout(function(){t.arrayPos++,t.replaceText(""),t.strings.length>t.arrayPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],0):(t.typewrite(t.strings[0],0),t.arrayPos=0)},this.fadeOutDelay)}},{key:"replaceText",value:function(t){this.attr?this.el.setAttribute(this.attr,t):this.isInput?this.el.value=t:"html"===this.contentType?this.el.innerHTML=t:this.el.textContent=t}},{key:"bindFocusEvents",value:function(){var t=this;this.isInput&&(this.el.addEventListener("focus",function(e){t.stop()}),this.el.addEventListener("blur",function(e){t.el.value&&0!==t.el.value.length||t.start()}))}},{key:"insertCursor",value:function(){this.showCursor&&(this.cursor||(this.cursor=document.createElement("span"),this.cursor.className="typed-cursor",this.cursor.innerHTML=this.cursorChar,this.el.parentNode&&this.el.parentNode.insertBefore(this.cursor,this.el.nextSibling)))}}]),t}();e["default"]=a,t.exports=e["default"]},function(t,e,s){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},o=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),a=s(2),u=n(a),l=function(){function t(){i(this,t)}return o(t,[{key:"load",value:function(t,e,s){if("string"==typeof s?t.el=document.querySelector(s):t.el=s,t.options=r({},u["default"],e),t.isInput="input"===t.el.tagName.toLowerCase(),t.attr=t.options.attr,t.bindInputFocusEvents=t.options.bindInputFocusEvents,t.showCursor=!t.isInput&&t.options.showCursor,t.cursorChar=t.options.cursorChar,t.cursorBlinking=!0,t.elContent=t.attr?t.el.getAttribute(t.attr):t.el.textContent,t.contentType=t.options.contentType,t.typeSpeed=t.options.typeSpeed,t.startDelay=t.options.startDelay,t.backSpeed=t.options.backSpeed,t.smartBackspace=t.options.smartBackspace,t.backDelay=t.options.backDelay,t.fadeOut=t.options.fadeOut,t.fadeOutClass=t.options.fadeOutClass,t.fadeOutDelay=t.options.fadeOutDelay,t.isPaused=!1,t.strings=t.options.strings.map(function(t){return t.trim()}),"string"==typeof t.options.stringsElement?t.stringsElement=document.querySelector(t.options.stringsElement):t.stringsElement=t.options.stringsElement,t.stringsElement){t.strings=[],t.stringsElement.style.display="none";var n=Array.prototype.slice.apply(t.stringsElement.children),i=n.length;if(i)for(var o=0;o<i;o+=1){var a=n[o];t.strings.push(a.innerHTML.trim())}}t.strPos=0,t.arrayPos=0,t.stopNum=0,t.loop=t.options.loop,t.loopCount=t.options.loopCount,t.curLoop=0,t.shuffle=t.options.shuffle,t.sequence=[],t.pause={status:!1,typewrite:!0,curString:"",curStrPos:0},t.typingComplete=!1;for(var o in t.strings)t.sequence[o]=o;t.currentElContent=this.getCurrentElContent(t),t.autoInsertCss=t.options.autoInsertCss,this.appendAnimationCss(t)}},{key:"getCurrentElContent",value:function(t){var e="";return e=t.attr?t.el.getAttribute(t.attr):t.isInput?t.el.value:"html"===t.contentType?t.el.innerHTML:t.el.textContent}},{key:"appendAnimationCss",value:function(t){var e="data-typed-js-css";if(t.autoInsertCss&&(t.showCursor||t.fadeOut)&&!document.querySelector("["+e+"]")){var s=document.createElement("style");s.type="text/css",s.setAttribute(e,!0);var n="";t.showCursor&&(n+="\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n "),t.fadeOut&&(n+="\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n "),0!==s.length&&(s.innerHTML=n,document.body.appendChild(s))}}}]),t}();e["default"]=l;var c=new l;e.initializer=c},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s={strings:["These are the default values...","You know what you should do?","Use your own!","Have a great day!"],stringsElement:null,typeSpeed:0,startDelay:0,backSpeed:0,smartBackspace:!0,shuffle:!1,backDelay:700,fadeOut:!1,fadeOutClass:"typed-fade-out",fadeOutDelay:500,loop:!1,loopCount:1/0,showCursor:!0,cursorChar:"|",autoInsertCss:!0,attr:null,bindInputFocusEvents:!1,contentType:"html",onBegin:function(t){},onComplete:function(t){},preStringTyped:function(t,e){},onStringTyped:function(t,e){},onLastStringBackspaced:function(t){},onTypingPaused:function(t,e){},onTypingResumed:function(t,e){},onReset:function(t){},onStop:function(t,e){},onStart:function(t,e){},onDestroy:function(t){}};e["default"]=s,t.exports=e["default"]},function(t,e){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var s=0;s<e.length;s++){var n=e[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,s,n){return s&&t(e.prototype,s),n&&t(e,n),e}}(),i=function(){function t(){s(this,t)}return n(t,[{key:"typeHtmlChars",value:function(t,e,s){if("html"!==s.contentType)return e;var n=t.substr(e).charAt(0);if("<"===n||"&"===n){var i="";for(i="<"===n?">":";";t.substr(e+1).charAt(0)!==i&&(e++,!(e+1>t.length)););e++}return e}},{key:"backSpaceHtmlChars",value:function(t,e,s){if("html"!==s.contentType)return e;var n=t.substr(e).charAt(0);if(">"===n||";"===n){var i="";for(i=">"===n?"<":"&";t.substr(e-1).charAt(0)!==i&&(e--,!(e<0)););e--}return e}}]),t}();e["default"]=i;var r=new i;e.htmlParser=r}])});
|
|
11
11
|
//# sourceMappingURL=typed.min.js.map
|