A very useful plugin for re-creating the effect of a typewriter in any number of HTML text nodes. jTypeWriter can handle the type writing of more than one nodes, and type the characters in sequential order, with a minimal footprint (2.8kb)!
In order to work you need the jQuery library (version 1.2.6+) and the javascript file of the jTypeWriter effect! Once you have them, link them inside the head of your html file:
don't forget to replace "folderName" with the folder that you've stored the two ".js" files.
jTypeWriter has been test for compatibility issues with the following broswers:
Probably it will work, with earlier versions of Opera and Safari, but I haven't try it out.
To properly use the jTypeWriter, you must first make sure that the DOM is ready to be traversed and manipulated. To acheive that the code of any jTypeWriter implementation must reside inside the event ready. For example let's assume you want to apply the jTypeWriter effect in the heading of your document which an <h1> with id="title" and you want the animation to last 1.5 seconds.
An alternative way to achieve the same thing, is to ensure that the jTypeWriter is placed after the DOM element that you want to handle. Although it's not the "appropriate" way, you could do it (for example the Google analytics javascript code, is placed before the end of the <body>).
jTypeWriter plugin can accept 6 different parameters that can fully change effect and the final outcome. Below you can find the list of parameters of jTypeWriter:
sequential:false and you have more than one DOM elements selected, the type writer for ALL effects will start and finish at the same time. The default value of this parameter is: true, which means that if you don't use it, it will type all text of all DOM elements in sequential order.text property and replace the default text. This parameter is not suggested for us if you try to aplly the jTypeWriter effect in multiple nodes, because the same text value (passed in the parameter) will replace the current text on each node. Maybe in next versions of jTypeWriter, I will change this parameter to accept arrays in order to replace the text values of multiple nodes. The default value of this parameter is: null, which means that the text of the selected DOM element(s) will not be affected.falsetrue, then the animation will NEVER end :). Each time the animation completes, the text will be removed and will start again. The default value of this parameter is: false. 0.loop is set to true and it controls the delay in seconds between loops. The default value is 0 which means, that in a loopable animation once the typing completes it will start all over again (very awkard for large chunks of text). $('h1.title').jTypeWriter({onComplete:functionName});loop: true, the function that you have provided for the onComplete event will be fired EVERY time the jTypeWriter complete the typing circle and starts a new one. Bellow you will find notes and explations on various advanced features:
In case you want to force the jTypeWriter effect to finish the animation before the completion of the duration circle, you can access a special function called: endEffect(). This function should be offered as a way to the user to prematurely end the jTyperWriter effect and read the text that it is been currently animated (in cases that the animated text or the duration is taking longer than anticipated). My suggestion is to bind that function to an event, probably some a click event in a button, placed near by the text. I would not suggest to place the button bellow the animated text, because as the text will be typed and new lines appear on the browser the button will be moved (unless you apply some good CSS).
Bellow I am displaying an example of forcing the jTypeWriter effect to end.
First of all in line (1) we must assign a variable to the returned value of the jTypeWriter effect, in this case I use a generic name obj1. In line (3) we are using the build in function endEffect() of obj1 to force end the animation, when the button is clicked in code line (2).
I have not taken into consideration the existance of any HTML elements or nodes inside the DOM nodes that the jTypeWriter affects. jTypeWriter must be used only inside nodes that have text, nothing else. For example if you want to animate the contets of an unordered or order list (<ul> or <ol>) you should select the list items (<li>)with jQuery.
For example: If you want to animate an unorder list with id="chapters", you should use: $('ul#chapters li').jTypeWriter();
instead of:
$('ul#chapters').jTypeWriter();
Image nodes are not an exception. Avoid applying jTypeWriter inside DOM nodes that have images inside (until I figure of a way of improving the plugin).
Use of jTypeWriter, without any parameters to a series of headings simple element.
CODE: $('.exampleA_Header').jTypeWriter();
Using jTypeWriter to this two paragraphs of text.
The type writer effect is continuous.
The first and most important parameter, is duration, by setting duration to any number (integer or decimal) you set the duratio of the typing effect.
By setting the type parameter to "words" we force the jTypeWriter to type words, not letters.
CODE: $('.exampleA_Header').jTypeWriter({duration:6.5,type:"words"});
This paragraphed will be typed, word-by-word and it will show very slowly since the duration is set to 6.5 seconds, which is rather slow for this size of text.
In this example we examine tree parameters of the jTypeWriter. If we set the sequential parameter to false then all the nodes selected with the initial query, will be typed in the same order.
Finally if we set the loop parameter to true, and the loopDelay to 5 then the animation will loop endlessly and will pause for 5 seconds between every loop!
CODE: $('.exampleC_Header').jTypeWriter({sequential:false, loop:true, loopDelay:5});
Type all DOM elements simultaneously...with a loop!
Very risky effect, but still it's available.
I wouldn't recommend it unless you have someting in mind.
Read Notes and Advanced Features, to see how you can force end the jTypeWriter effect.
If you want to do something when the jTypeWriter has finished, you can pass a function inside the onComplete parameter.
CODE: $('.exampleD_Header').jTypeWriter({sequential:false,loop:true});
When this paragraph finishes typing an alert message will be shown!
You can download a set of files, full of working examples. Click bellow to download it!
Download jTypeWriter v1.1 examples!order removed. Replaced with parameter: sequential, that accepts true or false.type. The new parameter is the third available and it's called: "phrase", allowing users to type whole phrases (clauses).type, parameter have changed from singular to plurar, "word" instead of "words" and "letter" instead of "letters". Default value is still "letter".loopDelay, it accepts numeric values and it defines the number of seconds to delay before the jTypeWriter goes in new loop. This parameter works in conjuction with, loop:type.jTypeWriter is released under GPL Open Source Licenses...thus it is completely and totally free!. You are obligated to keep all credits (links, names etc) and if you feel like it a link to this page will be appreciated!
Comments
Is it possible for each loop
Is it possible for each loop to write out different text rather than repeat the same text?
It can be done but...
I think it can be done, but there must be a single node selected and an array of strings to loop through. Currently though maybe I will include it in version :) 1.3.0.
;)) bravo ts@kI
;)) bravo ts@kI
Hmmmm
Nice effect, I will try to implement it in version 1.3.0. Currently I am completing version 1.2.0. and then I will give it a go. I am afraid that older browsers (for example IE 6.), would not be able to handle this kind of speed an quality in this kind of effect. Don't forget that what you saw was in Flash...and Flash is much faster!
nice _ another effect
nice! would you be able to add such text animation as this one? (see bottom) http://www.yugop.com/
Post new comment