Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<div id="quote">Deadlines are looming. You've got to deliver something that looks amazing, packed with lots of whiz-bang effects that run smoothly on various machines. No time to reinvent the wheel. You need a reliable tool set that helps you live up to your reputation as a coding Rock Star.</div>



  
  

  
  
  
              
            
!

CSS

              
                body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
#quote {
  -webkit-transform: translate3d(0, 0, 0);
  color: #dfdcff;
  font-size: clamp(2rem, 6rem, 4vw);
  line-height: 1.2;
  margin: 50px auto;
  width: 800px;
  visibility: hidden;
}

#quote div {
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
}

              
            
!

JS

              
                /*
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/
*/

var quote = document.getElementById("quote"),
    mySplitText = new SplitText(quote, {type:"words"}),
    tl = new TimelineMax({delay:0.5, repeat:10, repeatDelay:1}),
    numWords = mySplitText.words.length;

//prep the quote div for 3D goodness
TweenLite.set(quote, {transformPerspective:600, perspective:300, transformStyle:"preserve-3d", autoAlpha:1});


//intro sequence
for(var i = 0; i < numWords; i++){
  tl.from(mySplitText.words[i], 1.5, {z:randomNumber(-500,300), opacity:0, rotationY:randomNumber(-40, 40)}, Math.random()*1.5);
}
tl.from(quote, tl.duration(), {rotationY:180, transformOrigin:"50% 75% 200", ease:Power2.easeOut}, 0);

//randomly change z of each word, map opacity to z depth and rotate quote on y axis
for(var i = 0; i < numWords; i++){
  var z = randomNumber(-50,50)
  tl.to(mySplitText.words[i], 0.5, {z:z, opacity:rangeToPercent(z, -50, 50)}, "pulse");
}
tl.to(quote, 0.5, {rotationY:20}, "pulse");

//randomly change z of each word, map opacity to z depth and rotate quote on xy axis
for(var i = 0; i < numWords; i++){
  var z = randomNumber(-100,100)
  tl.to(mySplitText.words[i], 0.5, {z:z, opacity:rangeToPercent(z, -100, 100)}, "pulse2");
}
tl.to(quote, 0.5, {rotationX:-35, rotationY:0}, "pulse2");

//reset the quote to normal position
tl.to(mySplitText.words, 0.5, {z:0, opacity:1}, "reset")
tl.to(quote, 0.5, {rotationY:0, rotationX:0}, "reset");

//add explode label 2 seconds after reset animation is done
tl.add("explode", "+=2")
//add explode effect
for(var i = 0; i < numWords; i++){
  tl.to(mySplitText.words[i], 0.6, {z:randomNumber(100, 500), opacity:0, rotation:randomNumber(360, 720), rotationX:randomNumber(-360, 360), rotationY:randomNumber(-360, 360)}, "explode+=" + Math.random()*0.2);
}


//TRY THIS FOR SUPER-SLOW-MO
//tl.timeScale(0.2);



//some helper functions
function randomNumber(min, max){
	return Math.floor(Math.random() * (1 + max - min) + min);
}

function rangeToPercent(number, min, max){
    return ((number - min) / (max - min));
}
              
            
!
999px

Console