Skip to content

Instantly share code, notes, and snippets.

@majman
Created May 23, 2013 15:36
Show Gist options
  • Select an option

  • Save majman/5636979 to your computer and use it in GitHub Desktop.

Select an option

Save majman/5636979 to your computer and use it in GitHub Desktop.
A CodePen by GreenSock. Letter by Letter Animation - http://forums.greensock.com/topic/7440-fade-in-one-word-at-a-time/
<div id="textDiv">a quick sample of letter by letter animation</div>
var textDiv = $("#textDiv"),
sentence = textDiv.html().split(""),
tl = new TimelineMax({repeat:10, repeatDelay:0.4, yoyo:true});
TweenLite.set(textDiv, {css:{perspective:500, perspectiveOrigin:"50% 50%", transformStyle:"preserve-3d"}});
textDiv.html("");
$.each(sentence, function(index, val) {
if(val === " ") {
val = "&nbsp;"; }
var letter = $("<span/>", {id : "txt" + index}).html(val).appendTo(textDiv);
tl.to(letter, 1, {autoAlpha:1, ease:Back.easeOut, rotationX:360, transformOrigin:"50% 50% -20"}, index * 0.05);
});
body {
background-color:#000;
font-family: Arial, Helvetica, sans-serif;
margin: 10px;
color: #fff;
}
#textDiv span{
display:inline-block;
position:relative;
top:20px;
visibility:hidden;
font-size:36px;
-webkit-font-smoothing:antialiased;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment