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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="header-section">
        Scroll down to some different pinned content shown
    </div>

        <div class="content-container">

            <div class="row no-gutters">
                <div class="col-md-6">
                    <div class="right-content">
                        <div class="contentMarker px-5" data-marker-content="img1">
                            <h1>Section Heading</h1>
                            <p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot.</p>
                        </div>
                        <div class="contentMarker px-5" data-marker-content="img2">
                            <h1>Section Heading</h1>
                            <p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot.</p>
                        </div>
                        <div class="contentMarker px-5" data-marker-content="img3">
                            <h1>Section Heading</h1>
                            <p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot.</p>
                        </div>
                        <div class="contentMarker px-5" data-marker-content="img4">
                            <h1>Section Heading</h1>
                            <p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot.</p>
                        </div>
                        <div class="contentMarker px-5" data-marker-content="img5">
                            <h1>Section Heading</h1>
                            <p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot.</p>
                        </div>
                    </div>
                </div>
                <div class="col-md-5 ml-auto">
                    <div class="left-content">
                        <img id="img1" class="imageToShow" src="https://placekitten.com/300/700?image=1" alt="kitty">
                        <img id="img2" class="imageToShow" src="https://placekitten.com/300/700?image=2" alt="kitty">
                        <img id="img3" class="imageToShow" src="https://placekitten.com/300/700?image=3" alt="kitty">
                        <img id="img4" class="imageToShow" src="https://placekitten.com/300/700?image=4" alt="kitty">
                        <img id="img5" class="imageToShow" src="https://placekitten.com/300/700?image=5" alt="kitty">
                    </div>
                </div>
            </div>

       
  
 
</div>

<footer class="footer-section bg-dark p-5 text-center text-white">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequuntur, repellat.
</footer>
              
            
!

CSS

              
                .header-section {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #dbdbdb;
}
.content-container {
  display: flex;
}
.content-container > * {
  flex-basis: 100%;
}
.contentMarker{
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.right-content {
  padding-right: 15px;
}

.left-content {
  height: 100vh;
  position: relative;
}
.left-content img{
    position: absolute;
    height: 100%;
    width: 100%;
    object-fit: cover;
  opacity: 0;
  visibility: hidden;
}

//.left-content img#img1 {
//  opacity: 1;
//  visibility: visible;
//}

              
            
!

JS

              
                console.clear();

gsap.defaults({overwrite: 'auto'});


// Set up our scroll trigger
const ST = ScrollTrigger.create({
  trigger: ".content-container",
  start: "top top",
  end: "bottom bottom",
  onUpdate: getCurrentSection,
  pin: ".left-content"
});

const contentMarkers = gsap.utils.toArray(".contentMarker");

// Set up our content behaviors
contentMarkers.forEach(marker => {
  marker.content = document.querySelector(`#${marker.dataset.markerContent}`);
  
  gsap.set(marker.content, {transformOrigin: "center"});
    
    marker.content.enter = function() {
      gsap.fromTo(marker.content, {autoAlpha: 0, rotateY: -30}, {duration: 0.3, autoAlpha: 1, rotateY: 0});
    }
  
  marker.content.leave = function() {
    gsap.to(marker.content, {duration: 0.1, autoAlpha: 0});
  }
  
});

// Handle the updated position
let lastContent;
function getCurrentSection() {
  let newContent;
  
  //const currScroll = scrollY;
  const currScroll = scrollY - window.innerHeight;
  
  // Find the current section
  contentMarkers.forEach(marker => {
    if(currScroll > marker.offsetTop) {
      newContent = marker.content;
    }
  });
  
  // If the current section is different than that last, animate in
  if(newContent
  && (lastContent == null 
     || !newContent.isSameNode(lastContent))) {
    // Fade out last section
    if(lastContent) {
      lastContent.leave();
    }
    
    // Animate in new section
    newContent.enter();
    
    lastContent = newContent;
  }
  
}

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

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

Console