A demo showing multiple split types and effects. Part of the SplitText Collection
Created
December 5, 2013 09:44
-
-
Save hhypnos/7802730 to your computer and use it in GitHub Desktop.
A Pen by GreenSock.
This file contains hidden or 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
<link href='http://fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'> | |
<div id="nav"> | |
<button id="chars">chars</button> | |
<button id="words">words</button> | |
<button id="lines">lines</button> | |
<button id="charsWordsLines">chars words and lines</button> | |
<button id="revert">revert</button> | |
</div> | |
<div id="demo"> | |
<div id="quote">SplitText makes it easy to break apart the text in an HTML element so that each character, word, and/or line is wrapped in its own div tag.</div> | |
</div> | |
</div> | |
This file contains hidden or 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
/* | |
More SplitText demos on Codepen: http://codepen.io/collection/KiEhr | |
See http://www.greensock.com/splittext/ for details. | |
This demo uses SplitText which is a membership benefit of Club GreenSock, http://www.greensock.com/club/ | |
*/ | |
var $quote = $("#quote"), | |
mySplitText = new SplitText($quote, {type:"words"}), | |
tl = new TimelineLite(); | |
TweenLite.set($quote, {perspective:400}); | |
//kill any animations and set text back to its pre-split state | |
function kill(){ | |
tl.clear().time(0); | |
mySplitText.revert(); | |
} | |
$("#chars").click(function() { | |
kill(); | |
mySplitText.split({type:"chars, words"}) | |
tl.staggerFrom(mySplitText.chars, 0.6, {scale:4, autoAlpha:0, rotationX:-180, transformOrigin:"100% 50%", ease:Back.easeOut}, 0.02); | |
}) | |
$("#words").click(function() { | |
kill(); | |
mySplitText.split({type:"words"}) | |
$(mySplitText.words).each(function(index,el){ | |
tl.from($(el), 0.6, {opacity:0}, index * 0.01); | |
tl.from($(el), 0.6, {scale:index % 2 == 0 ? 0 : 2, ease:Back.easeOut}, index * 0.01); | |
}); | |
}) | |
$("#lines").click(function() { | |
kill(); | |
mySplitText.split({type:"lines"}) | |
tl.staggerFrom(mySplitText.lines, 0.5, {opacity:0, rotationX:-120, transformOrigin:"top center -150"}, 0.1); | |
}) | |
$("#charsWordsLines").click(function() { | |
kill(); | |
mySplitText.split({type:"chars, words, lines"}) | |
tl.staggerFrom(mySplitText.chars, 0.2, {autoAlpha:0, scale:4}, 0.01, 0.5) | |
.staggerTo(mySplitText.words, 0.1, {color:"#8FE402", scale:0.9}, 0.1, "words") | |
.staggerTo(mySplitText.words, 0.2, {color:"white", scale:1}, 0.1, "words+=0.1") | |
.staggerTo(mySplitText.lines, 0.5, {x:100, autoAlpha:0}, 0.2) | |
}) | |
//revert the text back to its pre-split state | |
$("#revert").click(function() { | |
mySplitText.revert(); | |
}) |
This file contains hidden or 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
body{ | |
font-family: Asap, Arial, Helvetica, sans-serif; | |
color:white; | |
background:black url(http://s.cdpn.io/16327/texture_bg.jpg) no-repeat 50% 0px; | |
margin:5% 20% 0 20%; | |
overflow:hidden; | |
} | |
#demo{ | |
position:relative; | |
} | |
#quote{ | |
font-size:40px; | |
line-height:50px; | |
color:#dedede; | |
} | |
button{ | |
padding:10px; | |
cursor:pointer; | |
} | |
#nav { | |
padding-bottom:20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment