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

              
                .home-page-wrapper
  .hero-container
    .bio-text
  .projects
    .project-grids
      .item
      .item
      .item

              
            
!

CSS

              
                body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.home-page-wrapper {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;

 .hero-container {
    width: 100%;
    height: 100vh;
    background-color: yellow;
    display: flex;
    align-items: center;
    justify-content: center;
  }

   .projects {
    width: 100%;
    height: 100vh;
    background-color: black;

    .project-grids {
      display: grid;
      grid-template-columns: repeat(3, 1fr); // Three columns
      gap: 20px; // Gap between grid items

      .item {
        width: 100%; // Full width of the grid container
        height: 50vh; // Initial height, will be set by GSAP animation
        // padding-top: 100%; // Maintain aspect ratio (assuming square items)
        background-color: aqua; // Background color

        &:nth-child(odd) {
          background-color: lightblue; // Alternate background color
        }
      }
    }
  }
}

              
            
!

JS

              
                

gsap.registerPlugin(ScrollTrigger);

document.addEventListener("DOMContentLoaded", function () {
  const container = document.querySelector(".home-page-wrapper");
  // const scrollbar = SmoothScrollbar.init(container, {
    const scrollbar = Scrollbar.init(container, {
    damping: 0.016,
    renderByPixel: true,
    effects: true,
  });

  // Update ScrollTrigger on SmoothScrollbar scroll event
  scrollbar.addListener(ScrollTrigger.update);

  // Set up ScrollTrigger scroller proxy for SmoothScrollbar
  ScrollTrigger.scrollerProxy(".home-page-wrapper", {
    scrollTop(value) {
      if (arguments.length) {
        scrollbar.scrollTop = value;
      }
      return scrollbar.scrollTop;
    },
    // Add other necessary properties
  });

  // Define the animation
  gsap.from(".project-grids > .item", {
    opacity: 0,
    y: -50,
    duration: 1,
    scrollTrigger: {
      trigger: ".project-grids",
      // start: "top 80%",
      // end: "bottom 20%",
      start: 'top bottom',
      end: '+=100%',
      scrub: true,
      scroller: '.home-page-wrapper'
    },
  });
});

              
            
!
999px

Console