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

              
                <div data-scroll-container class="smoothScroll">

  <div class="content-container">

    <div class="bufferzone"></div>

    <div class="part part-1">
      <div class="bg bg-1"></div>
      <div class="imger"></div>
    </div>

    <div class="part part-2">
      <div class="bg bg-2"></div>
      <div class="imger"></div>
    </div>

    <div class="part part-4">
      <div class="bg bg-4"></div>
      <div class="imger"></div>
    </div>

    <div class="part part-5">
      <div class="bg bg-5"></div>
      <div class="imger"></div>
    </div>

    <div class="part part-6">
      <div class="bg bg-6"></div>
      <div class="imger"></div>
    </div>

    <div class="part part-7">
      <div class="bg bg-7"></div>
      <div class="imger"></div>
    </div>

    <div class="bufferzone"></div>

  </div>
  
</div>

<div class="center-indicator"></div>
              
            
!

CSS

              
                html { 
  overflow: hidden; height: -webkit-fill-available; scroll-behavior: smooth; }


body { 
  background-color: #fff; margin: 0; padding: 0; transition: opacity ease-out 400ms; font-family: sans-serif; }

html, body{ 
  min-height: 100vh; }

.bufferzone {
  height:100vh;
    width:100vw;
}

.smoothScroll {
  background: orange
}

.content-container{
  display: flex;
  flex-direction: row;
  position: relative;
  width: auto;
  height: auto;
}

.part{
  display: flex;
  width: auto;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.bg{
  position: absolute;
  
  //width: 150vw; 
  width: 250vw; 
  height: 100vh;
  
  //transform: translate(150vw);
}

.bg-1 {
background: rgb(255,255,255);
background: linear-gradient(90deg, rgba(0,0,0,0) 0%, blue 15%, blue 85%, rgba(0,0,0,0) 100%);
    justify-content: center;
    align-items: center;
  }
  .bg-2{
background: rgb(255,255,255);
background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(236,244,12,1) 15%, rgba(236,244,12,1) 85%, rgba(0,0,0,0) 100%);
    color: #83448F;
    justify-content: center;
    align-items: center;
  }

  .bg-4{
   background: linear-gradient(90deg, rgba(0,0,0,0) 0%, blue 15%, blue 85%, rgba(0,0,0,0) 100%);
    color: #F3ECCF;
    justify-content: center;
    align-items: center;
  }

  .bg-5{
background: linear-gradient(90deg, rgba(0,0,0,0) 0%, yellow 15%, yellow 85%, rgba(0,0,0,0) 100%);
    color: #F3ECCF;
    justify-content: center;
    align-items: center;
  }

  .bg-6{
background: linear-gradient(90deg, rgba(0,0,0,0) 0%, orange 15%, orange 85%, rgba(0,0,0,0) 100%);
    color: #F3ECCF;
    justify-content: center;
    align-items: center;
  }
  .bg-7{
background: linear-gradient(90deg, rgba(0,0,0,0) 0%, purple 15%, purple 85%, rgba(0,0,0,0) 100%);
    color: #F3ECCF;
    justify-content: center;
    align-items: center;
  }
.imger {
  height: 80vh;
  width: 80vh;
  background-color: red;
  z-index: 999999;
  position: relative;
  margin-right: 10px;
}






// LOCOMOTIVE CSS (WILL NOT WORK WITHOUT THIS)
/*! locomotive-scroll v4.1.0 | MIT License | https://github.com/locomotivemtl/locomotive-scroll */
html.has-scroll-smooth {
  overflow: hidden; }

html.has-scroll-dragging {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none; }

.has-scroll-smooth body {
  overflow: hidden; }

.has-scroll-smooth [data-scroll-container] {
  min-height: 100vh; }

[data-scroll-direction="horizontal"] [data-scroll-container] {
  white-space: nowrap;
  height: 100vh;
  display: inline-block;
  white-space: nowrap; }

[data-scroll-direction="horizontal"] [data-scroll-section] {
  display: inline-block;
  vertical-align: top;
  white-space: nowrap;
  height: 100%; }

.c-scrollbar {
  position: absolute;
  right: 0;
  top: 0;
  width: 11px;
  height: 100%;
  transform-origin: center right;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0; }
  .c-scrollbar:hover {
    transform: scaleX(1.45); }
  .c-scrollbar:hover, .has-scroll-scrolling .c-scrollbar, .has-scroll-dragging .c-scrollbar {
    opacity: 1; }
  [data-scroll-direction="horizontal"] .c-scrollbar {
    width: 100%;
    height: 10px;
    top: auto;
    bottom: 0;
    transform: scaleY(1); }
    [data-scroll-direction="horizontal"] .c-scrollbar:hover {
      transform: scaleY(1.3); }

.c-scrollbar_thumb {
  position: absolute;
  top: 0;
  right: 0;
  background-color: black;
  opacity: 0.5;
  width: 7px;
  border-radius: 10px;
  margin: 2px;
  cursor: -webkit-grab;
  cursor: grab; }
  .has-scroll-dragging .c-scrollbar_thumb {
    cursor: -webkit-grabbing;
    cursor: grabbing; }
  [data-scroll-direction="horizontal"] .c-scrollbar_thumb {
    right: auto;
    bottom: 0; }


.center-indicator {
  position: absolute;
  width: 2px;
  height: 100%;
  background: green;
  left: calc(50vw - 1px);
  top: 0;
  z-index: 999;
}
              
            
!

JS

              
                

window.addEventListener( 'load', (event) => {

  let locoScrollDefaults = {
    el: document.querySelector('.smoothScroll'),
    smooth: true,
    direction: "horizontal",
  };
  let locoScroll = new LocomotiveScroll(locoScrollDefaults);


  // GSAP integration
  gsap.registerPlugin(ScrollTrigger);

  locoScroll.on("scroll", ScrollTrigger.update);

  ScrollTrigger.scrollerProxy(".smoothScroll", {
    scrollTop(value) {
      return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
    },
    scrollLeft(value) {
      return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.x;
    },
    getBoundingClientRect() {
      return {top: 0, left: 0, width: window.innerWidth, height: window.innerHeight};
    },
  });

  const projectTriggers = document.querySelectorAll(".part");

  projectTriggers.forEach(addTimeline);

  function addTimeline(project, index) {
    const bg = project.querySelector(".bg");

    const timeline = gsap.timeline({
      scrollTrigger: {
        trigger: project,
        scrub: 1,
        scroller: '.smoothScroll',
        //start: "left 70%",
        //end: "right 30%",
        start: () => 'left center+=' + window.innerHeight*0.4,
        end: () => 'right center-=' + window.innerHeight*0.4,
        invalidateOnRefresh: true,
        horizontal: true,
        //markers: true,
        snap: [0.5]
      }
    })
    .fromTo(bg, {
      x: '150vw',
      //x: () => { return (window.innerWidth*1.5) },
    },{
      x: '-150vw',
      //x: () => { return -(window.innerWidth*1.5) },
      ease:'none'
    })
    }

  
  // each time the window updates, we should refresh ScrollTrigger and then update LocomotiveScroll. 
  ScrollTrigger.addEventListener("refresh", () => locoScroll.update());

  // after everything is set up, refresh() ScrollTrigger and update LocomotiveScroll because padding may have been added for pinning, etc.
  ScrollTrigger.refresh();
    
});
              
            
!
999px

Console