Skip to content

Instantly share code, notes, and snippets.

@byronmejia
Created March 22, 2016 14:57
Show Gist options
  • Save byronmejia/c91752df6ba8ad7ea159 to your computer and use it in GitHub Desktop.
Save byronmejia/c91752df6ba8ad7ea159 to your computer and use it in GitHub Desktop.
// 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();
@spookybando
Copy link

Unit tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment