Created
March 22, 2016 14:57
-
-
Save byronmejia/c91752df6ba8ad7ea159 to your computer and use it in GitHub Desktop.
This file contains 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
// My quick hack to making a typing animation on screen, without silly JQuery... | |
// typeOut takes the: | |
// element: DOM element to manipulate | |
// string: string to type out | |
// delay: time between keystrokes | |
function typeOut (element, string, delay) { | |
for(var i = 0; i < string.length; i++){ | |
(function(){ | |
var tempI = i; | |
setTimeout(function(){ | |
document.getElementById(element).innerHTML = string.substr(0, tempI+1); | |
}, delay + delay * tempI); | |
})(); | |
} | |
} | |
function ready () { | |
typeOut('intro', 'Hello World...', 100); | |
} | |
document.onload = ready(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unit tests?