Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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 class="content content1">
  <h1>#1 Scale</h1>
  <div class="hello">Fires on page load</div>
  </div>
<div class="content content2">
  <h1>#2 Split Text</h1>
    <div class="message">GreenSock Rocks!</div>
  </div>
<div class="content content3">
  <h1>#3 Beware of Dog</h1>
  <div class="dog">
    <div class="woof"></div>
  </div>
</div>
<div class="content content4">
  <h1>#4 Fancy Div</h1>
  <div class="box">I'm Fancy</div>
  </div>
<div class="content content5">
  <h1>#5 Morphin' Time</h1>
<svg id="morphIt" xmlns="http://www.w3.org/2000/svg" width="400" height="300" viewBox="0 0 400 300">
 
  <path id="star" d="M200,33.21,238,110.1l84.85,12.33-61.4,59.85,14.5,84.51L200,226.89l-75.9,39.9,14.5-84.51L77.2,122.43l84.85-12.33Z" fill="#ffffff"/>
  <path id="circle" d="M302.5,150A102.5,102.5,0,1,1,200,47.5,102.5,102.5,0,0,1,302.5,150Z" fill="#fcee21"/>
  <path id="triangle" d="M319.65,253.62H80.35L200,46.38Z" fill="#fcee21"/>
</svg>
  </div>
<div class="content content6">
  <h1>#6 DrawSVG</h1>
    <svg id="drawIt" xmlns="http://www.w3.org/2000/svg" width="400" height="100" viewBox="0 0 400 100">
  
  
  <g stroke="white" stroke-width="2" fill="transparent">
    <path d="M42.83,128.61c-1.27,0-4.16.08-5.44.08H28.64a27.61,27.61,0,0,1-.51-5.61,28.44,28.44,0,0,1,.51-5.7H70.71a19.45,19.45,0,0,1,.69,5.19c0,4.51-2.21,6.12-7.15,6.12H61.79c-1.28,0-4.08-.08-5.36-.08h-.08c0,2.38.08,4,.08,6.29v40.54a39.7,39.7,0,0,1-6.8.52,39.13,39.13,0,0,1-6.8-.52Z" transform="translate(0 -99)"/>
    <path d="M109.47,157.42c0-2.38.09-4,.09-6.29-1.19,0-3.06.09-4.25.09H95.45c-1.19,0-3-.09-4.25-.09,0,2.3.08,3.91.08,6.29v18a38.5,38.5,0,0,1-6.8.52,40.36,40.36,0,0,1-6.8-.52V117.38a41.32,41.32,0,0,1,6.8-.51,39.41,39.41,0,0,1,6.8.51v16.24c0,2.38-.08,4-.08,6.29,1.27,0,3.06-.08,4.25-.08h9.86c1.19,0,3.06.08,4.25.08,0-2.29-.09-3.91-.09-6.29V117.38a45.66,45.66,0,0,1,13.61,0v58.06a37.4,37.4,0,0,1-6.64.52,41,41,0,0,1-7-.52Z" transform="translate(0 -99)"/>
    <path d="M175,169.15c-.68,4.25-3.74,6.55-8.67,6.55H143.73c-4.85,0-7.82-3.06-7.82-7.91V118l.59-.6h36.64a26,26,0,0,1,.51,5.36,19.52,19.52,0,0,1-1.19,6H149.25c0,2.29.09,3.91.09,6.12v5.95c2.21-.09,4.59-.09,5.78-.09h13a20.21,20.21,0,0,1,0,11.05H149.34v6.46c0,2.21-.09,3.83-.09,6.12v.09c2-.09,3.91-.17,6.29-.17h19.72A35.52,35.52,0,0,1,175,169.15Z" transform="translate(0 -99)"/>
    <path d="M242.41,169.15c-.68,4.25-3.74,6.55-8.67,6.55H211.13c-4.85,0-7.82-3.06-7.82-7.91V118l.59-.6h36.64a25.37,25.37,0,0,1,.51,5.36,19.24,19.24,0,0,1-1.19,6h-23.2c0,2.29.08,3.91.08,6.12v5.95c2.21-.09,4.59-.09,5.78-.09h13a20.46,20.46,0,0,1,0,11.05H216.74v6.46c0,2.21-.08,3.83-.08,6.12v.09c2-.09,3.91-.17,6.29-.17h19.72A34.16,34.16,0,0,1,242.41,169.15Z" transform="translate(0 -99)"/>
    <path d="M298.34,117.38v57.81a49.56,49.56,0,0,1-8.24.77,59.84,59.84,0,0,1-7.91-.52L268.85,145c-2-4.33-3.66-8.75-4.85-12l-.25.08c.59,7.23,1,18.36,1,25.42v16.91a33.54,33.54,0,0,1-6.21.52,36,36,0,0,1-6.46-.52v-57.8a46.83,46.83,0,0,1,8.07-.77,60.11,60.11,0,0,1,7.83.51l13.17,30.35c2.13,5,4.08,9.78,5.27,12.92l.34-.17c-.68-7.9-1-19.21-1-25.07V125c0-6,2.38-8.25,7.57-8.25h4.42Z" transform="translate(0 -99)"/>
    <path d="M348.83,171.7C344.92,174.76,338,176,333.28,176c-7.4,0-14-.18-21.43-.35l-.59-.59V117.81l.59-.6c7.32-.25,14-.34,21.43-.34,4.67,0,11.64,1.19,15.55,4.26,8,6.29,9.52,15.38,9.52,25.24S356.91,165.41,348.83,171.7Zm-15.64-44.2c-2.89,0-5.35,0-8.41-.08v38c3.06-.08,5.52-.08,8.41-.08,9.78,0,11.22-10.29,11.22-19S343,127.5,333.19,127.5Z" transform="translate(0 -99)"/>
  </g>
</svg>
  </div>
<div class="trigger triggerEnd">TriggerEnd</div>
<div class="trigger triggerStart">Trigger Start</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  padding: 0;
  margin: 0;
  font-family: "Roboto", sans-serif;
  color: white;
}

.content {
  width: 100%;
  height: 101vh;
  position: relative;
}

.content1 {
  background: slategray;
}
.content2 {
  background: forestgreen;
}
.content3 {
  background: midnightblue;
}
.content4 {
  background: indigo;
}
.content5 {
  background: goldenrod;
}
.content6 {
  background: cornflowerblue;
}

.dog {
  width: 163px;
  height: 161px;
  background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/314556/dog.png");
  position: absolute;
  top: 50%;
  left: 0;
}
.woof {
  width: 100px;
  height: 100px;
  background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/314556/woofCartoon.png");
  position: absolute;
  top: -60px;
  right: -70px;
  
}

h1 {
  padding: 20px;
  margin: 0;
  text-align: center;
  color: white;
}

.trigger {
  position: fixed;
  right: 10px;
  text-decoration: underline;
  
}

.box {
  width:150px;
  height: 100px;
  background-color: black;
  color: white;
  text-align: center;
  line-height: 100px;
  position: absolute;
  left: 50%;
  top: 25%;
}

.hello, .message, #morphIt, #drawIt {
  font-size: 60px;
  position: absolute;
  top:40%;
  left: 50%;
  width: 100%;
  text-align: center;
}

#triangle, #circle {
  visibility: hidden;
}

              
            
!

JS

              
                console.clear();
TweenLite.defaultEase = Linear.easeNone;
const startTrigger = 0.5;
const endTrigger = 0.9;
const range = 1/(endTrigger - startTrigger);
let thresholdRange = [];

for (let i = startTrigger; i <= endTrigger; i+=0.01) { 
  thresholdRange.push(i);
}
const options = {
  root: null,
  rootMargin: '0px',
  threshold: thresholdRange
};
const observer = new IntersectionObserver(animHandler, options);
const targets = document.querySelectorAll(".content");
const ar = [].slice.call(targets); 
let animations = [];



// create timelines and start observing targets
for(let [index, element] of ar.entries()) {
  animations[index] = new TimelineMax({paused:true});
  observer.observe(element);
}


TweenMax.set(".dog", {yPercent:-50, xPercent:-100});
TweenMax.set(".box, .hello, .message, #morphIt, #drawIt", {yPercent:-50, xPercent:-50});
TweenMax.set(".triggerStart", {bottom:startTrigger * 100 + "%"});
TweenMax.set(".triggerEnd", {bottom:endTrigger * 100 + "%"});

// timeline for each section
animations[0].from(".hello", 1, {scale:0, transformOrigin:"center bottom"});

let mySplitText = new SplitText(".message", {type:"chars, words, lines"});
animations[1].staggerFrom(mySplitText.chars, 0.2, {y: -50, rotation:180, opacity: 0}, 0.05);

animations[2].to(".dog", 0.5, {left:"50%", xPercent:-50});
animations[2].from(".woof", 0.22, {scale:0, transformOrigin:"left bottom"}, "-=0.1");

animations[3].to(".box", 0.5, {rotation:360});
animations[3].to(".box", 0.5, {top:"50%", width:300, backgroundColor:"white", color:"black"});

animations[4].to("#star", 0.5, {morphSVG:"#circle"});
animations[4].to("#star", 0.5, {morphSVG:"#triangle"}, "+=0.5");
animations[4].to("#star", 0.5, {morphSVG:"#star"}, "+=0.5");

animations[5].staggerFromTo("#drawIt path", 1, {drawSVG:0}, {drawSVG:true},0.1);
animations[5].staggerTo("#drawIt path", 0.5, {fill:'white'}, 0.1, 0.5);

// observer handler
function animHandler(targets, observer) {
  for (var entry of targets) {
    if (entry.isIntersecting) {
      let i = ar.indexOf(entry.target);
      let prog = ((entry.intersectionRatio)-startTrigger)*range;
      if (prog < 0) {
        animations[i].progress(0);
      } else if (prog > 0.97) {
        animations[i].progress(1);
        observer.unobserve(entry.target);
      } else {
        animations[i].progress(prog);
      }
      
    } else {
        return;
    }
  }
}
              
            
!
999px

Console