Created
February 11, 2014 08:12
-
-
Save zirosas/8930970 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var txt = $('.writer').text(); | |
var timeOut; | |
var txtLen = txt.length; | |
var char = 0; | |
$('.writer').text('|'); | |
(function typeIt() { | |
var humanize = Math.round(Math.random() * (200 - 30)) + 30; | |
timeOut = setTimeout(function() { | |
char++; | |
var type = txt.substring(0, char); | |
$('.writer').text(type + '|'); | |
typeIt(); | |
if (char == txtLen) { | |
$('.writer').text($('.writer').text().slice(0, -1)); // remove the '|' | |
clearTimeout(timeOut); | |
} | |
}, humanize); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment