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 class="section1">
  <div class="background">
      <div class="image img0 zero">
        <video src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4" controls autoplay muted playsinline />
      </div>
  </div>
  
  <div class="container">
      <div class="content content0">
    <div class="copy0">
    Video Intro Area
      <button id="skip">Skip</button>
    </div>
  </div>
  </div>
</div> -->


<div class="section2">
  
    
<div class="background">
      <div class="image img7 three"></div>
      <div class="image img6 four"></div>
      <div class="image img5 five"></div>
      <div class="image img4 six"></div>
      <div class="image img3 seven"></div>
      <div class="image img2 two"></div>
      <div class="image img1 one"></div>

    </div>
    
<div class="container2">

  <div class="content content1">
      <div class="absolute test1">
        
      </div>
    <p class="copy1">W3DOCS</p>  
  </div>
  <div class="content content2">
      <p class="copy2">Spicy jalapeno bacon ipsum dolor amet pork belly cow tri-tip, andouille turkey pig shank shankle biltong sirloin pork loin brisket ball tip. Porchetta capicola filet mignon, prosciutto chuck flank ham hock tongue tenderloin beef ribs. Tri-tip corned beef biltong kielbasa ball tip beef ribs ham sausage pig hamburger ribeye pancetta short ribs kevin. Ribeye chuck ground round rump bacon. Tail tongue pork loin t-bone, swine alcatra tri-tip jowl strip steak frankfurter boudin pancetta porchetta turducken. Ham fatback kevin, andouille ground round tenderloin rump drumstick pastrami landjaeger jowl.</p>
    </div>
    <div class="content content3"><p class="copy3">W3DOCS</p>
      <div class="absolute test3">Test floating stuff (code removed)</div>
    </div>
    <div class="content content4">
      <p class="copy4">W3DOCS</p></div>
    <div class="content content5"><p class="copy5">W3DOCS</p></div>
    <div class="content content6"><p class="copy6">W3DOCS</p></div>
  <div class="content content7"><p class="copy7">W3DOCS</p></div>
</div>
</div>
              
            
!

CSS

              
                body,
      html {
        height: 100%;
        margin: 0;
        font-family: Helvetica, sans-serif;
      }
.section2 {
  // display:none;
}
video {
  margin: 0 auto;
  height: 100vh;
  display: block;
}
.container,
.container2 {
  max-height: 100vh;
	overflow-y: scroll;
  // scroll-snap-type: y mandatory;
  position: relative;
}
.content {
  // scroll-snap-align: start;
  position: relative;
}

.absolute {
  position: absolute;
  top: 0;
}

.test1 {
  background: red;
  width: 20rem;
  height: 20rem;
}

.background {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: scroll;
  
}
      .image {
        width: 100%;
position: absolute;
        height: 100%;
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
      }
      .one {
        background-image: url("https://images.unsplash.com/photo-1523240795612-9a054b0db644?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80")
      }
      .two {
        background-image: url("https://images.unsplash.com/photo-1501504905252-473c47e087f8?ixlib=rb-1.2.1&auto=format&fit=crop&w=967&q=80")
      }
      .three {
        background-image: url("https://images.unsplash.com/photo-1521737604893-d14cc237f11d?ixlib=rb-1.2.1&auto=format&fit=crop&w=1063&q=80")
      }
      .four {
        background-image: url("https://images.unsplash.com/photo-1519389950473-47ba0277781c?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80")
      }
      .five {
        background-image: url("https://images.unsplash.com/photo-1522071820081-009f0129c71c?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80")
      }
      .six {
        background-image: url("https://images.unsplash.com/photo-1488190211105-8b0e65b80b4e?ixlib=rb-1.2.1&auto=format&fit=crop&w=1500&q=80")
      }
      .seven {
        background-image: url("https://images.unsplash.com/photo-1543269865-96ae30571b5a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80")
      }
      .content {
        background-color: rgba(0, 0, 0, 0.5);
        color: #fff0c2;
        font-weight: bold;
        // font-size: 60px;
        border: 4px dashed red;
        position: relative;
        // top: 50%;
        left: 50%;
        transform: translateX(-50%);
        z-index: 2;
        width: 270px;
        // padding: 50px;
        text-align: center;
        height: 1000px;
      }
              
            
!

JS

              
                function setupOneOffs() {
  
  let panel1 = gsap.timeline({
    // yes, we can add it to an entire timeline!
    scrollTrigger: {
      trigger: ".content1",
      pin: false,   // pin the trigger element while active
      start: "top top", // when the top of the trigger hits the top of the viewport
      end: "+=50", // end after scrolling 500px beyond the start
      //scrub: 1, // smooth scrubbing, takes 1 second to "catch up" to the scrollbar
      snap: {
        snapTo: "labels", // snap to the closest label in the timeline
        //duration: {min: 0.2, max: 3}, // the snap animation should be at least 0.2 seconds, but no more than 3 seconds (determined by velocity)
        //delay: 0.2, // wait 0.2 seconds from the last scroll event before doing the snapping
        //ease: "power1.inOut" // the ease of the snap animation ("power3" by default)
      }
    }
  });

// add animations and labels to the timeline
panel1.addLabel("start")
  .from(".test1", {x: -500, scale: .3, rotation:45})
  .addLabel("color")
  .from(".test1", {backgroundColor: "#28a92b"})
  .addLabel("spin")
  .to(".test1", {rotation: 360, x: 0})
  .addLabel("end");
};

function setUpSection2() {
  const SECTION_MAX = 7;
  for(let i = 1; i < SECTION_MAX; i += 1) {
    gsap.to('.img' + i, {
        opacity: 0,
        ease: 'none',
        scrollTrigger: {
          markers: true,
          scroller: ".container2",
          trigger: '.content' + i,
          start: 'top top',
          end: '100%',
          scrub: true,
          pin: ".copy" + i,
          snap: {
            snapTo: i
          }
        }
      });
    gsap.to('.copy' + i, {
        opacity: 0,
        ease: 'none',
        scrollTrigger: {
          markers: true,
          scroller: ".container2",
          trigger: '.content' + i,
          start: 'top top',
          end: '+=500',
          scrub: true,
        }
      });
  }
  setupOneOffs();
};
$(function() {
  function skip() {
    console.log('jfc')
    $('video').get(0).pause();
    $('.section1').hide();
    $('.section2').show();
    setUpSection2();
  }
  // setUpSection2();
  $('#skip').on('click', skip);
  $('video').on('ended', function() {
    $('.section1').hide();
    $('.section2').show();
    // setTimeout(function() {
      setUpSection2();
    // }, 1000)
  })
})

setUpSection2();



              
            
!
999px

Console