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="wrap">
  <h2 class="scroll" >SCROLL</h2>

  <div class="slide slide01">
    <p class="green green01">GREEN</p>
    <p class="green green02">GREEN</p>
    <p class="green green03">&nbsp GREEN<span>er</span></p>
  </div>

  <div class="slide slide02">
    <div class="quote center">
      <p>"You might not need ScrollMagic ...</p>
      <p class="when">when using GSAP."</p>
      <p class="osu">Quote: osublake</p>
    </div>
    
    <h2 class="center">TWEEN</h2>
    <h2 class="center">by</h2>
    <h2 class="center">TWEEN</h2>
    
  </div>
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Montserrat:900&display=swap');

body {
  margin:0;
  background-color:grey;
  height: 3000px;
  font-family:sans-serif;
  text-align: center;
  color: #616161;
}

#wrap{
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  text-align: center;
}

.center{
  position:absolute;
  top:50%;
  left:50%;
}


.slide{
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:100%;
}
.green{
  position: absolute;
  left: 50%;
  width:100%;
  font-size: 40px;
  font-weight: 800;
  margin: 0;
  color: #227922;
}
.green01{
  top:100px
}
.green02{
  top: 140px;
  font-size: 55px;
}
.green03{
  top: 192px;
  font-size: 63px;
}
.green03 span{
  position: relative;
  font-size: 41px;
  top: -33px;
}

.slide02{
  left:100%;
  background-color:green;

}

.slide02 p{
  font-size: 30px;
  margin: 0;
  color: #3c3c3c;
  font-weight: 800;
  width: 505px;
  text-align: left;
  visibility:hidden;
}

.osu{
  position: relative;
  text-align: right !important;
  font-size: 15px !important;
  visibility:hidden;
}

.slide02 h2{
  position: absolute;
  top: 50%;
  margin: 0;
  font-size: 80px;
  font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  color: #333333;
  visibility:hidden;
}
              
            
!

JS

              
                console.clear();

var sceneStart = window.innerHeight;
var triggerOffset = document.documentElement.clientHeight;
var dur = window.innerHeight;

var requestId = null;

gsap.set('.green',{xPercent:100});
gsap.set('.center',{xPercent:-50, yPercent:-50});

var action = gsap.timeline({paused: true, defaults: {ease: "none"}})
.to('.scroll', {autoAlpha:0, duration: 250},sceneStart)
.to('.green', {xPercent:-50, duration: dur/2, ease: "back.out(1.5)", stagger:500},sceneStart)
.addLabel("slide02", "+=600")
.to('.slide01, .slide02', {x:'-100%', duration: dur}, 'slide02')
.to('.slide02 p', {autoAlpha:1, stagger: dur/2}, "+=200")
.to('.quote', {rotationX:90, transformOrigin:'center bottom', duration: dur*1}, "+=300")
.addLabel("stagger", "+=500")
.to('.slide02 h2', {autoAlpha:1, scale:1.3, transformOrigin:'center', duration:100, stagger:500}, 'stagger')
.to('.slide02 h2', {autoAlpha:0, scale:0, transformOrigin:'center', duration:100, stagger:500}, 'stagger+=500')

.to({}, {duration: dur*4}) // 'empty' tween to prolong the timeline




// ==========================
window.addEventListener("scroll", requestUpdate);

update();

// Only update on animation frames
function requestUpdate() {
  if (!requestId) {
    requestId = requestAnimationFrame(update);
  }
}

// Set timeline time to scrollTop
function update() {
  action.time(window.pageYOffset + triggerOffset);
  requestId = null;
  
  var totalTime = action.totalTime(); 
  console.log(totalTime);
  gsap.set('body', {height:totalTime + 500})
}



              
            
!
999px

Console