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

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

              
                <body>
  <header>
    <h1>Hero image</h1>
  </header>
  <div class="first-pinned-section">
    <h1>First static section</h1>
  </div>
  
  <div class="trigger-container">
  
  <ul id="container">   
    
    <li class="project">
      <p class="project-infos">
          <span>01 Subject 1</span>
      </p>
      <div class="project__inner">
        <div class="project-container">
          <div class="project-container__inner">
          <div class="first">
            <div class="first-item"><h3>first-child content</h3></div>
            <div class="first-item"><h3>first-child content</h3></div>
            <div class="first-item"><h3>first-child content</h3></div>
            <div class="first-item"><h3>first-child content</h3></div>
          </div>
          </div>
        </div>
        <a href="">Nom du projet</a>
      </div>
    </li>
    <li class="project">
      <div class="project__inner">
        <p class="project-infos">
          <span>02 Subject 2</span>
        </p>
        <div class="project-container">
          <div class="project-container__inner">
            <div class="first">
          <div class="first-item"><h3>second-child content</h3></div>
          <div class="first-item"><h3>second-child content</h3></div>
          <div class="first-item"><h3>second-child content</h3></div>
          <div class="first-item"><h3>second-child content</h3></div>
      </div>
          </div>
        </div>
        <a href="">Nom du projet</a>
      </div>
    </li>
    <li class="project">
      <div class="project__inner">
        <p class="project-infos">
          <span>03 Subject 3</span>
        </p>
        <div class="project-container">
          <div class="project-container__inner">
            <div class="first">
          <div class="first-item"><h3>third-child content</h3></div>
          <div class="first-item"><h3>third-child content</h3></div>
          <div class="first-item"><h3>third-child content</h3></div>
          <div class="first-item"><h3>third-child content</h3></div>
      </div>
        </div>
        <a href="">Nom du projet</a>
      </div>
    </li>
    </ul>
</div>
  <footer>
    <h1>footer content</h1>
  </footer>
</body>
              
            
!

CSS

              
                body{
  padding: 0;
  margin: 0;
  overflow-x: hidden
}
header,
footer{
  height:100vh;
  background-color: white;
}

footer {
  float: left;
}
h1{
  position: relative;
  text-align: center;
  margin-top:50px;
}
.first-pinned-section {
  height:100vh;
  padding: 20px;
  background: rgb(249,164,76);
background: -moz-linear-gradient(180deg, rgba(249,164,76,1) 0%, rgba(249,112,76,1) 51%, rgba(249,92,76,1) 100%);
background: -webkit-linear-gradient(180deg, rgba(249,164,76,1) 0%, rgba(249,112,76,1) 51%, rgba(249,92,76,1) 100%);
background: linear-gradient(180deg, rgba(249,164,76,1) 0%, rgba(249,112,76,1) 51%, rgba(249,92,76,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#f9a44c",endColorstr="#f95c4c",GradientType=1);
}

.double-pinned-parent {
  position: relative;
  background-color: white;
  border-radius: 24px;
}
.first{
  display: flex;
  background-color: #fff;
  width: 5100px;
  padding: 100px 0;
}
.first-item{
  height: 300px;
  width: 300px;
  border: 2px solid black;
  color: black;
}
.second{
  display: inline-block;
  width: 5100px;
  padding: 100px 0;
}
.second-item{
  height: 300px;
  width: 300px;
  border: 2px solid black
}



.trigger-container{
  position: relative;
  height: 100vh;
  -webkit-transform: translate3d(0,0,0);
  will-change:transform;
  backface-visibility: hidden;
  
  #container {
    width: 100%;
    height: 100%; 
    max-height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    list-style: none;
    padding: 0;
    margin-top: 0vh;
    will-change:transform;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    backface-visibility: hidden;
 
    
    .project {
      position: absolute;
      width: 100%;
      height: 100%;
      max-height: 100vh;
      text-align: center;
      color: white;
      box-sizing: border-box;
      padding: 0;
      will-change: transform;
      border-bottom: 1px solid black;
      background: white;
      will-change:transform;
      -webkit-transform: translate3d(0,0,0);
      transform: translate3d(0,0,0);
      backface-visibility: hidden;
      
      &:nth-child(1){
        top: 85vh;
      }
      
      &:nth-child(2){
        top: 90vh;
      }
      
      &:nth-child(3){
        top: 95vh;
      }
      
      
      .project__inner{
        position: relative;
        width: 100%;
        height: 100%;
      }
      
      .project-container {
        overflow: hidden;
        height: 100vh;
        box-sizing: border-box;
        margin: 0;

        &__inner{
          position: relative;
          width: 100%;
          height: 100%;
          will-change: auto;

          img{
            height: 100%;
            object-fit: cover;
            width: 100%;
          }
        }
      }
      
      .project-infos{
        display: flex;
        justify-content: flex-start;
        height: 5vh;
        align-items: center;
        overflow: hidden;
        margin: 0 auto;
        max-width: 1680px;
        padding: 0 1.4vw;
        position: relative;
        width: 100vw;
        line-height: 1.2;
        color: black;
      }

      a{
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        opacity: 0;
        height: 100%;
        display: block;
      }
    }
  }
}


              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger)

// first section pinned to simulate the static image on the page.
ScrollTrigger.create({
  trigger: ".first-pinned-section",
  start: () => "top top",
  end: () => "+=3000px",
  pin: true,
  pinSpacing: false,
  markers: true
})

// gsap.set("#container", {x: 0, y: 0});  
// gsap.set(".project", {y:'85%'});  

// Project stack FX
let projects = gsap.utils.toArray('.project');
console.log('jfrfhsfa')


// Timeline and scrolltrigger is based on the container.
// the container is pinned, and the three projects are positioned absolute at the bottom to start and then transitioned upward.
let tl = gsap.timeline({
  scrollTrigger: {
    trigger: ".trigger-container",
    start: "top top",
    end: () => "+=" + ((projects.length ) * window.innerHeight),
    scrub: true,
    pin: true, 
    force3D: true,
    invalidateOnRefresh: true,
    markers: true,
  }
});

// for each of the projects, the top is changed from 85vh to 0vh for the first service, 90vh to 0vh for the second service and 95vh to 0vh for the third service. Should maybe based on the project-infos height.
projects.forEach((project, i) => {
  tl
    .to(project, {
    y: () => "-=" + (85 + (5*i)) + "%", 
    // top: () => "-=" + (85 + (5)) + "%", 
    ease: "none",
    force3D: true,
    rotation: 0.01
  });
});       

// adjusts z-index
gsap.set(".project", {zIndex: (i, target, targets) => targets.length + i});

// not sure if this is needed
// ScrollTrigger.refresh();









              
            
!
999px

Console