#Typer
Typer is an Angular directive that simulates someone typing and deleting over a list of words. The directive is highly customisable and allows the words to be set by passing an array of strings as an attribute, the transition times can be set on the directive aswell as callback functions to get invoked after each action ('Type', 'Delete', 'Highlight')
full list of directive options or advanced examples
include the typer directive source file in your html
<script src="path/to/typer.js"></script>
Mark the typer module as a dependency of your angular app
angular.module('myApp', ['typer']);
npm install angular-typer
Using a module bundler such as webpack or browserify require the typer module as a dependency of your angular app
var angular = require('angular');
angular.module('app', [
require('angular-typer')
]);
bower install angular-typer
include the typer directive source file in your html
<script src="bower_components/angular-typer/dist/typer.min.js"></script>
Mark the typer module as a dependency of your angular app
angular.module('myApp', ['typer']);
Then declare the typer directive in your HTML
<typer words="['JavaScript', 'Angular', 'Cats']" type-time='150' backspace-time='200' start-delay='1500' highlight-background='#2980b9'></typer>
Note: The directive will inherit the styles of its parent element so it is recommended to nest it like below
<h1 class="main-title">I love <typer words="['JavaScript', 'Angular', 'Cats']" type-time='150' backspace-time='200' start-delay='1500' highlight-background='#2980b9'></typer></h1>
Note: all times are in milliseconds
- words
- start-typing
- start-trigger
- repeat
- shuffle
- start-delay
- pause
- type-time
- backspace-time
- on-typed
- on-deleted
- on-complete
- highlight-background
- highlight-color
- highlight-time
- cursor
Array of strings to loop over and simulate someone typing out each single word
words="['Angular', 'React', 'Ember']"
Set whether the directives first animation is either the type or delete/highlight
defaults to false
start-typing="true"
Set a boolean variable on the directive that will start the directive when the variable changes to true
Note: start-delay is taken into account
start-trigger="vm.controllerTrigger"
set whether to continuously loop over the words, defaults to true
repeat="false"
set whether to randomly shuffle the array of words, defaults to false
shuffle="true"
set the time before the first action happens, defaults to 0ms since v0.5.6 (500ms before)
start-delay="2000"
set the time between each transition (excluding the start time), defaults 1000ms
pause="500"
set the time for each character to be typed out, defaults to 250ms
type-time="300"
set the time for each character to be deleted, defaults to type-time
backspace-time="150"
function to be executed when a word is fully typed
on-typed="vm.alert('typed')"
function to be executed when a word is fully deleted
on-deleted="vm.alert('deleted')"
function to be executed when all the words are typed, will only excute if repeat is set to false
on-complete="vm.alert('complete')"
background color of highlight transition, if set this will replace the backspace transition
highlight-background="#2980b9"
color the text for highlight transition, defaults to white (#FFFFFF)
highlight-color="#2ecc71"
unlike the backspace time which is for each character the highlight time is for the overall transition, defaults to 250ms
highlight-time="400"
set a custom cursor, defaults to '|'
note the cursor will not be set if the highlight-color is set
cursor="@"
include the following CSS for the cursor blinking effect
.typer__cursor--blink {
-webkit-animation: blink 1s infinite;
-moz-animation: blink 1s infinite;
animation: blink 1s infinite;
}
@-webkit-keyframes blink {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@-moz-keyframes blink {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@keyframes blink {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
Contributions are welcome. Please be sure to document your changes.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- fix shuffle bug
- publish to NPM
- boolean attributes except either a boolean value or a string representation of the boolean
- start-trigger
- clear timers on destroy
- custom cursor
- UMD support
- Travis CI
- shuffle words feature
- refactor of link function
- watch words array for changes
- startTyping functionality
- set the default repeat attribute to true
- initial release
MIT