typed.js 2.0.7 → 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 ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ singleQuote: true,
3
+ arrowParens: "always"
4
+ }
package/README.md CHANGED
@@ -2,61 +2,58 @@
2
2
  [![Code Climate](https://codeclimate.com/github/mattboldt/typed.js/badges/gpa.svg)](https://codeclimate.com/github/mattboldt/typed.js)
3
3
  [![GitHub release](https://img.shields.io/github/release/mattboldt/typed.js.svg)]()
4
4
  [![npm](https://img.shields.io/npm/dt/typed.js.svg)](https://img.shields.io/npm/dt/typed.js.svg)
5
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
6
- [![Gratipay User](https://img.shields.io/gratipay/user/mattboldt.svg)](https://gratipay.com/Typed.js/)
7
5
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/mattboldt/typed.js/master/LICENSE.txt)
8
6
 
9
7
  <img src="https://raw.githubusercontent.com/mattboldt/typed.js/master/logo-cropped.png" width="450px" title="Typed.js" />
10
8
 
11
- ### [View the Live Demo](http://www.mattboldt.com/demos/typed-js/) | [View All Demos](http://www.mattboldt.com/typed.js) | [View Full Docs](http://www.mattboldt.com/typed.js/docs) | [mattboldt.com](http://www.mattboldt.com)
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)
12
10
 
13
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.
14
12
 
15
13
  ---
16
14
 
17
- Installation
18
- ------------
15
+ ## Installation
19
16
 
20
- #### NPM
17
+ #### Choose One
21
18
 
22
- ~~~
19
+ ```
23
20
  npm install typed.js
24
- ~~~
25
-
26
- #### Yarn
27
-
28
- ~~~
29
21
  yarn add typed.js
30
- ~~~
22
+ bower install typed.js
23
+ ```
31
24
 
32
- #### Bower
25
+ #### CDN
33
26
 
34
- ~~~
35
- bower install typed.js
36
- ~~~
27
+ ```html
28
+ <script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11"></script>
29
+ ```
37
30
 
38
31
  #### Setup
39
32
 
40
33
  This is really all you need to get going.
41
34
 
42
- ~~~ javascript
35
+ ```javascript
43
36
  // Can also be included with a regular script tag
44
37
  import Typed from 'typed.js';
45
38
 
46
39
  var options = {
47
- strings: ["<i>First</i> sentence.", "&amp; a second sentence."],
40
+ strings: ['<i>First</i> sentence.', '&amp; a second sentence.'],
48
41
  typeSpeed: 40
49
- }
42
+ };
50
43
 
51
- var typed = new Typed(".element", options);
52
- ~~~
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
53
50
 
54
- Wonderful sites using Typed.js
55
- ---
56
51
  https://slack.com/
57
52
 
58
53
  https://envato.com/
59
54
 
55
+ https://gorails.com/
56
+
60
57
  https://productmap.co/
61
58
 
62
59
  https://www.typed.com/
@@ -65,103 +62,111 @@ https://apeiron.io
65
62
 
66
63
  https://git.market/
67
64
 
68
- http://allison.house/404
69
-
70
- http://www.maxcdn.com/
71
-
72
65
  https://commando.io/
73
66
 
74
67
  http://testdouble.com/agency.html
75
68
 
76
- http://www.stephanemartinw.com/
77
-
78
- http://www.trelab.fi/en/
69
+ https://www.capitalfactory.com/
79
70
 
80
- http://jessejohnson.github.io/
71
+ http://www.maxcdn.com/
81
72
 
73
+ https://www.powerauth.com/
82
74
 
83
75
  ---
84
76
 
85
77
  ### Strings from static HTML (SEO Friendly)
78
+
86
79
  Rather than using the `strings` array to insert strings, you can place an HTML `div` on the page and read from it.
87
80
  This allows bots and search engines, as well as users with JavaScript disabled, to see your text on the page.
88
81
 
89
- ~~~ javascript
82
+ ```javascript
90
83
  <script>
91
84
  var typed = new Typed('#typed', {
92
85
  stringsElement: '#typed-strings'
93
86
  });
94
87
  </script>
95
- ~~~
88
+ ```
96
89
 
97
- ~~~ html
90
+ ```html
98
91
  <div id="typed-strings">
99
- <p>Typed.js is a <strong>JavaScript</strong> library.</p>
100
- <p>It <em>types</em> out sentences.</p>
92
+ <p>Typed.js is a <strong>JavaScript</strong> library.</p>
93
+ <p>It <em>types</em> out sentences.</p>
101
94
  </div>
102
95
  <span id="typed"></span>
103
- ~~~
96
+ ```
104
97
 
105
98
  ### Type Pausing
106
99
 
107
100
  You can pause in the middle of a string for a given amount of time by including an escape character.
108
101
 
109
- ~~~ javascript
110
- var typed = new Typed(".element", {
102
+ ```javascript
103
+ var typed = new Typed('.element', {
111
104
  // Waits 1000ms after typing "First"
112
- strings: ["First ^1000 sentence.", "Second sentence."]
105
+ strings: ['First ^1000 sentence.', 'Second sentence.']
113
106
  });
114
- ~~~
107
+ ```
115
108
 
116
109
  ### Smart Backspacing
117
110
 
118
111
  In the following example, this would only backspace the words after "This is a"
119
112
 
120
- ~~~ javascript
121
- var typed = new Typed(".element", {
122
- strings: ["This is a JavaScript library", "This is an ES6 module"],
113
+ ```javascript
114
+ var typed = new Typed('.element', {
115
+ strings: ['This is a JavaScript library', 'This is an ES6 module'],
123
116
  smartBackspace: true // Default value
124
117
  });
125
- ~~~
118
+ ```
126
119
 
127
120
  ### Bulk Typing
128
121
 
129
- 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.
130
123
 
131
- ~~~ javascript
132
- var typed = new Typed(".element", {
133
- strings: [
134
- "git push --force ^1000\n `pushed to origin with option force`"
135
- ]
124
+ ```javascript
125
+ var typed = new Typed('.element', {
126
+ strings: ['git push --force ^1000\n `pushed to origin with option force`']
136
127
  });
137
- ~~~
128
+ ```
138
129
 
139
130
  ### CSS
140
131
 
141
132
  CSS animations are built upon initialzation in JavaScript. But, you can customize them at your will! These classes are:
133
+
142
134
  ```css
143
135
  /* Cursor */
144
- .typed-cursor {}
136
+ .typed-cursor {
137
+ }
145
138
 
146
139
  /* If fade out option is set */
147
- .typed-fade-out {}
140
+ .typed-fade-out {
141
+ }
148
142
  ```
149
143
 
150
144
  ### Use with ReactJS
151
145
 
152
146
  Check out this example React app using Typed.js in a component: https://jsfiddle.net/mattboldt/ovat9jmp/
153
147
 
148
+ ### Use with Vue.js
149
+
150
+ Check out the Vue.js component: https://github.com/Orlandster/vue-typed-js
151
+
152
+ ### Use it as WebComponent
154
153
 
155
- Customization
156
- ----
154
+ Check out the WebComponent: https://github.com/Orlandster/wc-typed-js
157
155
 
158
- ~~~ javascript
159
- var typed = new Typed(".element", {
156
+ ## Customization
157
+
158
+ ```javascript
159
+ var typed = new Typed('.element', {
160
160
  /**
161
161
  * @property {array} strings strings to be typed
162
162
  * @property {string} stringsElement ID of element containing string children
163
163
  */
164
- strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'],
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
+ ],
165
170
  stringsElement: null,
166
171
 
167
172
  /**
@@ -235,6 +240,12 @@ var typed = new Typed(".element", {
235
240
  */
236
241
  contentType: 'html',
237
242
 
243
+ /**
244
+ * Before it begins typing
245
+ * @param {Typed} self
246
+ */
247
+ onBegin: (self) => {},
248
+
238
249
  /**
239
250
  * All typing is complete
240
251
  * @param {Typed} self
@@ -301,15 +312,13 @@ var typed = new Typed(".element", {
301
312
  */
302
313
  onDestroy: (self) => {}
303
314
  });
304
- ~~~
305
-
315
+ ```
306
316
 
307
317
  ## Contributing
308
318
 
309
319
  ### [View Contribution Guidelines](./.github/CONTRIBUTING.md)
310
320
 
311
- end
312
- ---
321
+ ## end
313
322
 
314
323
  Thanks for checking this out. If you have any questions, I'll be on [Twitter](http://www.twitter.com/atmattb).
315
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
- onComplete: function(self) { prettyLog('onComplete ' + self) },
10
- preStringTyped: function(pos, self) { prettyLog('preStringTyped ' + pos + ' ' + self); },
11
- onStringTyped: function(pos, self) { prettyLog('onStringTyped ' + pos + ' ' + self) },
12
- onLastStringBackspaced: function(self) { prettyLog('onLastStringBackspaced ' + self) },
13
- onTypingPaused: function(pos, self) { prettyLog('onTypingPaused ' + pos + ' ' + self) },
14
- onTypingResumed: function(pos, self) { prettyLog('onTypingResumed ' + pos + ' ' + self) },
15
- onReset: function(self) { prettyLog('onReset ' + self) },
16
- onStop: function(pos, self) { prettyLog('onStop ' + pos + ' ' + self) },
17
- onStart: function(pos, self) { prettyLog('onStart ' + pos + ' ' + self) },
18
- onDestroy: function(self) { prettyLog('onDestroy ' + self) }
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: ['Some <i>strings</i> with', 'Some <strong>HTML</strong>', 'Chars &times; &copy;'],
64
+ strings: [
65
+ 'Some <i>strings</i> with',
66
+ 'Some <strong>HTML</strong>',
67
+ 'Chars &times; &copy;'
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: ['My strings are: <i>strings</i> with', 'My strings are: <strong>HTML</strong>', 'My strings are: Chars &times; &copy;'],
79
+ strings: [
80
+ 'My strings are: <i>strings</i> with',
81
+ 'My strings are: <strong>HTML</strong>',
82
+ 'My strings are: Chars &times; &copy;'
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: ['1 Some <i>strings</i> with', '2 Some <strong>HTML</strong>', '3 Chars &times; &copy;'],
100
+ strings: [
101
+ '1 Some <i>strings</i> with',
102
+ '2 Some <strong>HTML</strong>',
103
+ '3 Chars &times; &copy;'
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: ['npm install^1000\n`installing components...` ^1000\n`Fetching from source...`'],
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.7",
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
- return gulp.src('src/*.js')
14
- // default: use local linting config
15
- .pipe(eslint())
16
- // format ESLint results and print them to the console
17
- .pipe(eslint.format())
18
- .pipe(eslint.failAfterError());
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.src('src/*.js')
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(uglify({
27
- preserveComments: 'license',
28
- compress: {
29
- /*eslint-disable */
30
- negate_iife: false
31
- /*eslint-enable */
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.src('./src/*.js')
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.src('./src/*.js')
48
- .pipe(gulpDocumentation('html'), {}, {
49
- name: 'Typed.js Docs',
50
- version: '2.0.7'
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
- gulp.run('styles:css');
66
- server.notify(event);
67
- //pipe support is added for server.notify since v0.1.5,
68
- //see https://github.com/gimm/gulp-express#servernotifyevent
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']);