Created
June 8, 2013 02:17
-
-
Save SaraSoueidan/5733661 to your computer and use it in GitHub Desktop.
Typing + Highlighting Animation (Demo: Typewriter and highlighter effects with CSS3 transitions: http://jsbin.com/ogevob/1/edit)
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
$.fn.animateText = function(delay, klass) { | |
var text = this.text(); | |
var letters = text.split(''); | |
return this.each(function(){ | |
var $this = $(this); | |
$this.html(text.replace(/./g, '<span class="letter">$&</span>')); | |
$this.find('span.letter').each(function(i, el){ | |
setTimeout(function(){ $(el).addClass(klass); }, delay * i); | |
}); | |
}); | |
}; | |
//usage | |
$('p').animateText(15, 'foo'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment