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="home-section">
        <div class="home-section-text-wrapper">
          <p class="home-trigger-1 home-trigger"><span>Lorem ipsum dolor sit amet consectetur adipisicing elit.</span></p>
          <h1 class="home-trigger-2 home-trigger"><span>LAsperiores et blanditiis nulla natus.</span></h1>
          <p class="home-trigger-3 home-trigger"><span> Voluptates in facere quos similique et non placeat sit tempora vel, deserunt, aperiam molestiae labore rem nemo.</span></p>
        </div>
      </section>
              
            
!

CSS

              
                .home-section {
  position: relative;
  padding: 1.25rem 0;
  height: 300vh;
  border: 1px solid;
}

.home-section-text-wrapper {
  text-align: center;
}

.home-section-text-wrapper > * {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.home-section-text-wrapper > * span {
  font-family: "Rubik", sans-serif;
  font-weight: 400;
  color: #323548;
  height: 3.125rem;
  line-height: 3.125rem;

  // opacity: 0; 
  // transform: translateY(100%); // instead of setting aniation values in CSS use GSAP .from() to have all the logic in one place!
  visibility: hidden; // Read more about FOUC https://greensock.com/fouc/
}

.home-section-text-wrapper .home-trigger-1,
.home-section-text-wrapper .home-trigger-3 {
  font-size: 1.5rem;
}

.home-section-text-wrapper .home-trigger-2 {
  font-size: 3rem;
}

              
            
!

JS

              
                const duration = 1;
const stagger = 2;
const timelineHome = gsap.timeline({
  repeat: -1, // While testing loop the animation remove when done
  defaults: { // instead of repeating the same values for tweens put them in the defaults: {} object
    duration: duration,
    ease: "power2.in"
  },
  // scrollTrigger: {
  //   trigger: '.home-section',
  //   start: "top top",
  //   end: "bottom bottom",
  //   scrub: 1,
  //   markers: true,
  //   pin: true
  // }
});
// Read more about FOUC https://greensock.com/fouc/
gsap.set('.home-section-text-wrapper > * span',  { autoAlpha: 1}) 
// Same as your CSS you can target all the elelements
timelineHome.from('.home-section-text-wrapper > * span', {
  yPercent: 100, // Insetad of setting transform: translateY(100%); in CSS use a .from() tween now all your logic is in GSAP and much easer to manage.
  opacity: 0,
  stagger: stagger // By staggering the elements you're creating the same effect 
});
timelineHome.to('.home-section-text-wrapper > * span', {
  yPercent: -100, // Instead of trageting the property transfrom GSAP can target them direcly x, xPercent, y, yPercent, scale, rotate, ect
  opacity: 0,
  stagger: stagger
}, duration); // Make move out animation  start when first elments is done animating
              
            
!
999px

Console