Created
January 10, 2016 16:22
-
-
Save kindlyfire/4b35966cb5a7966342ef 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
function Typed() | |
{ | |
self = this; | |
self.delay = 50; | |
self.pos = 1; | |
self.text = ""; | |
function init(elem, delay) { | |
self.delay = delay; | |
self.text = $(elem).html(); | |
} | |
this.type = function(elem, delay) | |
{ | |
if(self.text == "") init(elem, delay); | |
if(self.pos > self.text.length) return true; | |
$(elem).html(self.text.substr(0, self.pos)); | |
self.pos++; | |
window.setTimeout(function() { | |
self.type(elem, self.delay); | |
}, self.delay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment