type text effect
by Craig Martin
HTML
<div id="type-here"></div>
JavaScript
//class is in
$title = "222";
var posttitle = $title
var Typewriter = new Class({
//implements
Implements: [Options],
//options
options: {
container: $(document.body),
message: '',
delay: 150,
cursor: 0
},
//initialization
initialize: function(options) {
//set options
this.setOptions(options);
},
//start the typewriter
start: function() {
//for every letter
for(x = 0; x < this.options.message.length; x++) {
//spit out the letter
var id = this.setLetter.delay(this.options.delay * x, this);
}
},
//place the newest letter in the container
setLetter: function() {
this.options.container.set('html',this.options.container.get('html') + '' + this.options.message.charAt(this.options.cursor));
//increment cursor
this.options.cursor++;
}
});
var t = new Typewriter({
container: $('type-here'),
message: posttitle,
delay:100
}).start();