1

SplitText: Character Animation with staggers

 2 years ago
source link: https://codepen.io/GreenSock/pen/bGrPgxw
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Pen Settings

HTML Preprocessor

Add Class(es) to <html>

Stuff for <head>

0 unsaved changes
xxxxxxxxxx
<link href='//fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'>
<h1 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.</h1>
<button id="animate">animate</button>
xxxxxxxxxx
body{
  font-family: 'Asap', Arial, Helvetica, sans-serif;
  color:white;
  background:black url(//s3-us-west-2.amazonaws.com/s.cdpn.io/16327/texture_bg.jpg) no-repeat 50% 0px;
  margin:3% 10% 0 10%;
  overflow:hidden;
}
#quote{
  font-size:44px;
  line-height:50px;
  color:#dedede;
  font-weight: 300;
}
button {
  padding:10px;
  margin: 20px 0;
}
xxxxxxxxxx
/*
See https://www.greensock.com/splittext/ for details. 
This demo uses SplitText which is a membership benefit of Club GreenSock, https://www.greensock.com/club/
*/
gsap.registerPlugin(SplitText);
var tl = gsap.timeline(),
  mySplitText = new SplitText("#quote", { type: "words,chars" }),
  chars = mySplitText.chars; //an array of all the divs that wrap each character
gsap.set("#quote", { perspective: 400 });
console.log(chars);
tl.from(chars, {
  duration: 0.8,
  opacity: 0,
  scale: 0,
  y: 80,

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK