# j-Typed

> Config is the same as [typed.js](https://github.com/mattboldt/typed.js#customization). The only difference is that all keys are lowercase. This is to maintain consistency with other components. The on

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 7afa86321c566d14f0d9e3fa8254aaacfa6ed3a86b67308319f22ecb8ccba507
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- Based on [typed.js](https://github.com/mattboldt/typed.js/) by [Matt Boldt](https://github.com/mattboldt)
- Value must be __array__


__Configuration__:

Config is the same as [typed.js](https://github.com/mattboldt/typed.js#customization). The only difference is that all keys are lowercase. This is to maintain consistency with other components. The only added configuration is `id`

- __NEW__: `selector {String}` can contain a nested element for rendering text
- __NEW__: `text {String}` in the form `Text 1|Text 2|Text 3|Text N` otherwise text is loaded according to the `path`
- `typespeed {Number}` in milliseconds (default: `0`)
- `startdelay {Number}` in milliseconds (default: `0`)
- `backspeed {Number}` in milliseconds (default: `0`)
- `smartbackspace {Boolean}` this would only backspace the words after "This is a" (default: `true`)
- `shuffle {Boolean}` shuffle the strings (default: `true`)
- `backdelay {String}` time before backspacing (default: `700`)
- `fadeout {Boolean}` fade out instead of backspace (default: `false`)
- `fadeoutclass {String}` css class for fade animation (default: `typed-fade-out`)
- `fadeoutdelay {Number}` fade out delay in milliseconds (default: `500`)
- `loop {Boolean}` loop strings (default: `false`)
- `loopcount {String/Number}` amount of loops (default: `Infinity`)
- `showcursor {Boolean}` show cursor (default: `true`)
- `cursorchar {String}` cursor character (default: `|`)
- `autoinsertcss {Boolean}` insert CSS for cursor and fadeOut into HTML `<head>` (default: `true`)
- `contenttype {String}` contentType `html` or `null` for plaintext (default: `html`)

__Global events__:

Again, same as [typed.js](https://github.com/mattboldt/typed.js#customization). Added `component` parameter

- `ON('typed.onComplete', function(typed, component) {})`
- `ON('typed.preStringTyped', function(pos, typed, component) {})`
- `ON('typed.onStringTyped', function(pos, typed, component) {})`
- `ON('typed.onLastStringBackspaced', function(typed, component) {})`
- `ON('typed.onTypingPaused', function(pos, typed, component) {})`
- `ON('typed.onTypingResumed', function(pos, typed, component) {})`
- `ON('typed.onReset', function(typed, component) {})`
- `ON('typed.onStop', function(pos, typed, component) {})`
- `ON('typed.onStart', function(pos, typed, component) {})`
- `ON('typed.onDestroy', function(typed, component) {})`

Use it with `<ui-component name="typed">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Denis Granec. Source: the Componentator components repository, MIT license.

```html example.html
<div style="height:100px">
	<ui-component name="typed" path="messages" config="loop:true" style="white-space:pre"></ui-component>
</div>
<div style="height:50px">
	<ui-component name="typed" path="messages2" config="loop:true;typespeed:100;backspeed:50"></ui-component>
</div>

<script>
	var messages = 'npm install total.js^1000\n`+ <b>total.js@3.1.0</b>` ^1000\n`added <b>1 package</b> from 23 contributors and audited 1 package in <b>1.348s</b>` ^1000\n`found 0 vulnerabilities`';
	var messages2 = ['Hello world!', '<b>Total.js</b> is awesome!', 'jComponent is <b>awesome</b>!', 'Lorem ipsum', 'Lorem dolor'];

	var count = 0;
	ON('typed.onComplete', function(typed, component) {
		if (typed.el.id === 'myconsole') {
			count++;

			if (count === 5)
				typed.loop = false;
		}
	});
</script>
```
