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

              
                <section class="h-screen bg-gray-400 grid place-items-center">
  <h2 class="text-6xl font-bold">Scroll.</h2>
</section>


<section id="Demo" class="Demo relative overflow-x-hidden">
  <div class="wrapper mx-auto h-screen">
    <div class="indicators">
      <div class="indicator"></div>
      <div class="indicator"></div>
      <div class="indicator"></div>
    </div>
    
    <div class="Demo-section" data-color="#ffffff">
      <article>
        <h2 class="font-bold text-6xl mb-8">Title 1</h2>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </article>
      <div class="HardwareLockup flex items-start justify-center relative">
        <img src="https://assets.codepen.io/11487/Macbook+Pro+2021+16_+%283%29.svg" />

        <div class="HardwareLockup-media absolute">
          <video width="320" height="240" autoplay loop muted class="video w-full h-auto max-w-full">
            <source src="https://assets.codepen.io/11487/bluprint-cis-level-1-1152x720.mp4" type="video/mp4">
          Your browser does not support the video tag.
          </video> 
        </div>
      </div>      
    </div>
    
    <div class="Demo-section" data-color="#ddd">
      <article>
        <h2 class="font-bold text-6xl mb-8">Title 2</h2>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </article>
      <div class="HardwareLockup flex items-start justify-center relative">
        <img src="https://assets.codepen.io/11487/Macbook+Pro+2021+16_+%283%29.svg" />

        <div class="HardwareLockup-media absolute">
          <video width="320" height="240" autoplay loop muted class="video w-full h-auto max-w-full">
            <source src="https://assets.codepen.io/11487/fingers.mp4" type="video/mp4">
          Your browser does not support the video tag.
          </video> 
        </div>
      </div>  
    </div>
    
    <div class="Demo-section" data-color="#999">
      <article>
        <h2 class="font-bold text-6xl mb-8">Title 3</h2>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </article>
      <div class="HardwareLockup flex items-start justify-center relative">
        <img src="https://assets.codepen.io/11487/Macbook+Pro+2021+16_+%283%29.svg" />

        <div class="HardwareLockup-media absolute">
          <video width="320" height="240" autoplay loop muted class="video w-full h-auto max-w-full">
            <source src="https://assets.codepen.io/11487/macdaddy.mp4" type="video/mp4">
          Your browser does not support the video tag.
          </video> 
        </div>
      </div>  
    </div>

    
  </div>
</section>





<section class="h-screen bg-gray-400 grid place-items-center">
  <h2 class="text-6xl font-bold">Dassit</h2>
</section>
              
            
!

CSS

              
                // .active {
//   background: red;
// }

.indicators {
  left: 2rem;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  height: 400px;
  width: 3px;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  position: absolute;
  z-index: 20;
}

.indicator {
  width: 100%;
  background-color: #adadad;
  flex-grow: 1;
  margin: 2px 0;
}

.Demo-section {
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 4rem;
  outline: 1px solid red;
  // position: absolute;
  top: 0;
  justify-content: space-between;
/*   background-color: #fff; */
}



.Demo-section article {
  // flex-basis: 50%;
  // margin-right: auto;
  margin-left: 2rem;
  max-width: 600px;
}

.Demo-section img {
  // flex-basis: 35%;
  // max-width: 1200px;
  height: auto;
}


.HardwareLockup {
  // display: flex;
  // align-items: flex-start;
  // justify-content: center;
  // position: relative;
  max-width: 1370px;
  margin: 3rem auto;
  transform: translateX(200px);
}

.HardwareLockup-media {
  // position: absolute;
  top: 42px;
  left: 9%;
  right: 9%;
  bottom: auto;  
  // width: 1122px;
  // height: 701px;
  // max-width: 100%;
  // max-height: auto;
  // background: red;
}

.HardwareLockup-media video {
  // max-width: 100%;
  // height: auto;
}

#Demo {
  background-color: white;
}
              
            
!

JS

              
                ScrollTrigger.defaults({
  markers: false
});

let demoSections = gsap.utils.toArray(".Demo-section");
let indicators = gsap.utils.toArray(".indicator");

let height = 250 * demoSections.length;

gsap.set(".indicators", { display: "flex" });

let tl = gsap.timeline({
  // duration: demoSections.length,
  scrollTrigger: {
    trigger: ".Demo .wrapper",
    start: "top top",
    end: "+=" + height + "%",
    scrub: true,
    pin: ".Demo .wrapper",
    pinSpacing: true,
    id: "demoSections",
    // toggleClass: "active"
  }
});

// let bg = gsap.timeline({
//   scrollTrigger: {
//     trigger: "article",
//     start: "center center",
//     // end: "+=900",
//     toggleClass: "active"
//   },
// });

// let pinner = gsap.timeline({
//   scrollTrigger: {
//     trigger: ".Demo .wrapper",
//     start: "top top",
//     end: "+=" + height + "%",
//     scrub: true,
//     pin: ".Demo .wrapper",
//     pinSpacing: true,
//     id: "pinning",
//     markers: true    
//   }
// });

demoSections.forEach(function (elem, i) {
  var color = elem.getAttribute('data-color');
  // console.log('i is: ',i)
  gsap.set(elem, { position: "absolute", top: 0 });

  tl.to(indicators[i], { 
    backgroundColor: "orange", 
    duration: 0.5 
  }, i);
  
  tl.from(elem.querySelectorAll(".HardwareLockup"), { 
    autoAlpha: 0
  }, i);
  
  tl.from(elem.querySelector("article"), { 
    autoAlpha: 0, 
    y: 220 
  }, i);
  
    // tl.to(elem, { 
    //   backgroundColor: color, 
    //   // duration: 0.5 
    // }, i);    
  
    tl.to("#Demo", { 
      backgroundColor: color
    }, i);   
  if (i != demoSections.length - 1) {
    tl.to(
      indicators[i], { 
        backgroundColor: "#adadad", 
        duration: 0 
      }, i + 0.8
    );  
    
    tl.to(elem.querySelector("article"), { 
      autoAlpha: 0, 
      y: -220 
    }, i + 0.8);
    
    tl.to(elem.querySelectorAll(".HardwareLockup"), { 
      autoAlpha: 0
    }, i + 1);
    
    
  }
});



// const media = window.matchMedia("screen and (max-width: 600px)");
// ScrollTrigger.addEventListener("refreshInit", checkSTState);
// checkSTState();

// function checkSTState() {
//   if(media.matches) {
//     tl.disable();
//   } else {
//     tl.enable();
//   }
// }
              
            
!
999px

Console