Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="home">
  <h1>TEST SCROLLTRIGGER</h1>
</div>
<div class="tooltip">
  <img class="tooltip-img" src="https://images.unsplash.com/photo-1617507910383-9597c6f287c3?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYxODI1NzIzMw&ixlib=rb-1.2.1&q=80&w=400">
</div>
<div class="sections">
<div class="section s1">
  <div class="content">
    <h2>Lorem ipsum dolor sit amet.</h2>
    <p>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda
      suscipit, eligendi a aperiam vel ex quod at debitis, sint explicabo
      nostrum natus, recusandae est. Mollitia amet laborum accusamus sequi
    </p>
  </div>
</div>
<div class="section s2">
  <div class="content">
    <h2>Lorem ipsum dolor sit amet.</h2>
    <p>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda
      suscipit, eligendi a aperiam vel ex quod at debitis, sint explicabo
      nostrum natus, recusandae est. Mollitia amet laborum accusamus sequi
      expedita quo nesciunt quis sint tempora amet iure mollitia magnam quam
      aperiam, cum earum. Adipisci libero qui quo id totam. Quidem labore
      ullam laboriosam beatae blanditiis soluta a minus provident alias
      consequatur unde sapiente, repudiandae eum, modi, officiis ipsa enim
      reprehenderit praesentium illum consequuntur assumenda in rerum
      dignissimos quis. Necessitatibus quam autem dolores enim quos quiaectus sapiente a cum excepturi, expedita odio natus pariatur?
      Repellat tempore id autem blanditiis odit architecto pariatur
      provident ipsum nemo. Facilis reprehenderit, soluta, rem officiis,
      ipsa nobis ex quia quasi harum reiciendis sunt nam quam quos!
    </p>
  </div>
</div>
<div class="section s3">
  <div class="content">
    <h2>Lorem ipsum dolor sit amet.</h2>
    <p>
      aperiam, cum earum. Adipisci libero qui quo id totam. Quidem labore
      ullam laboriosam beatae blanditiis soluta a minus provident alias
      consequatur unde sapiente, repudiandae eum, modi, officiis ipsa enim
      reprehenderit praesentium illum consequuntur assumenda in rerum
      dignissimos quis. Necessitatibus quam autem dolores enim quos quia
      natus earum commodi tenetur, suscipit expedita ea deserunt fugiat
      incidunt, provident exercitationem dolor vitae quisquam! Praesentium
      ullam delectus sapiente a cum excepturi, expedita odio natus pariatur?
      Repellat tempore id autem blanditiis odit architecto pariatur
      provident ipsum nemo. Facilis reprehenderit, soluta, rem officiis,
      ipsa nobis ex quia quasi harum reiciendis sunt nam quam quos!
    </p>
  </div>
</div>
<div class="section s4">
  <div class="content">
    <h2>Lorem ipsum dolor sit amet.</h2>
    <p>
      reprehenderit praesentium illum consequuntur assumenda in rerum
      dignissimos quis. Necessitatibus quam autem dolores enim quos quia
      natus earum commodi tenetur, suscipit expedita ea deserunt fugiat
      incidunt, provident exercitationem dolor vitae quisquam! Praesentium
      ullam delectus sapiente a cum excepturi, expedita odio natus pariatur?
      Repellat tempore id autem blanditiis odit architecto pariatur
      provident ipsum nemo. Facilis reprehenderit, soluta, rem officiis,
      ipsa nobis ex quia quasi harum reiciendis sunt nam quam quos!
    </p>
  </div>
</div>
</div>
<footer>
  <h2>some space after the sections</h2>
</footer>
              
            
!

CSS

              
                *, ::before, ::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
}

.home {
    width: 100%;
    height: 100vh;
    background: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #f1f1f1;
}

.home h1 {
    font-size: 60px;
    text-transform: uppercase;
    padding-bottom: 100px;
}

.section {
 
}
.content {
    padding: 20px 10px;
    max-width: 700px;
    margin: 0 auto;
}
.content h2 {
    font-size: 60px;
    padding: 30px 0 20px;
}
.content p {
    font-size: 26px;
}
.s1 {
    background: sandybrown;
}
.s2 {
    background: lightskyblue;
}
.s3 {
    background: rgb(179, 246, 179);
}
.s4 {
    background: goldenrod;
}

.tooltip {
    background: #fff;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: auto;
    position: absolute;
    padding: 10px;
    border-radius: 5px;
    text-transform: uppercase;
}
.tooltip img {
    width: 90px;
}

footer {
  margin-top: 50vh;
  margin-bottom: 50vh;
}
              
            
!

JS

              
                const src = [
  "https://placekitten.com/200/300",
  "https://placekitten.com/800/800",
  "https://placekitten.com/300/100",
  "https://placekitten.com/500/500"
];

gsap.to('.tooltip', {
  scrollTrigger: {
    trigger: ".sections",
    start: "top 40%",
    end: "bottom bottom",
    pin: ".tooltip"
  }
})

const sections = gsap.utils.toArray(".section");

sections.forEach((section, index) => {
  gsap.to(section, {
    scrollTrigger: {
      trigger: section,
      start: 'top center',
      end: 'bottom center',
      markers: true,
      onEnter: () => {
        console.log(index, 'entering');
        gsap.set(".tooltip-img", {
          attr: { src: src[index] }
        });
      },
      onEnterBack: () => {
        console.log(index, 'entering back');
        gsap.set(".tooltip-img", {
          attr: { src: src[index] }
        });
      }
    }
  });
});

              
            
!
999px

Console