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 class="background">
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
   <span></span>
</div>

<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 {
   
}

.content-container{
 mix-blend-mode: difference;  
  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;
}


@keyframes move {
    100% {
        transform: translate3d(0, 0, 1px) rotate(360deg);
    }
}

.background {
    position: absolute;
    width: 100%;
    height: 100vh;
    top: 0;
    left: 0;
    background: #ffffff;
    overflow: hidden;
}

.background span {
    width: 12vmin;
    height: 12vmin;
    border-radius: 12vmin;
    backface-visibility: hidden;
    position: absolute;
    animation: move;
    animation-duration: 48;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}


.background span:nth-child(0) {
    color: #e23b03;
    top: 91%;
    left: 30%;
    animation-duration: 8s;
    animation-delay: -7s;
    transform-origin: 4vw 6vh;
    box-shadow: 24vmin 0 3.9381380061624265vmin currentColor;
}
.background span:nth-child(1) {
    color: #ef0148;
    top: 64%;
    left: 67%;
    animation-duration: 6s;
    animation-delay: -7s;
    transform-origin: -18vw -12vh;
    box-shadow: -24vmin 0 3.578512614173838vmin currentColor;
}
.background span:nth-child(2) {
    color: #ef0148;
    top: 68%;
    left: 28%;
    animation-duration: 19s;
    animation-delay: -12s;
    transform-origin: 15vw 17vh;
    box-shadow: 24vmin 0 3.9011805035316343vmin currentColor;
}
.background span:nth-child(3) {
    color: #db0a2a;
    top: 38%;
    left: 34%;
    animation-duration: 23s;
    animation-delay: -9s;
    transform-origin: -10vw -20vh;
    box-shadow: 24vmin 0 3.9746003934238843vmin currentColor;
}
.background span:nth-child(4) {
    color: #db0a2a;
    top: 49%;
    left: 38%;
    animation-duration: 25s;
    animation-delay: -2s;
    transform-origin: 16vw 21vh;
    box-shadow: 24vmin 0 3.1633782402147355vmin currentColor;
}
.background span:nth-child(5) {
    color: #ef0148;
    top: 40%;
    left: 6%;
    animation-duration: 12s;
    animation-delay: -2s;
    transform-origin: -11vw 14vh;
    box-shadow: -24vmin 0 3.528883340548677vmin currentColor;
}
.background span:nth-child(6) {
    color: #ef0148;
    top: 96%;
    left: 21%;
    animation-duration: 22s;
    animation-delay: -9s;
    transform-origin: 25vw 6vh;
    box-shadow: -24vmin 0 3.5003279316412277vmin currentColor;
}
.background span:nth-child(7) {
    color: #e23b03;
    top: 70%;
    left: 12%;
    animation-duration: 19s;
    animation-delay: -10s;
    transform-origin: -23vw -1vh;
    box-shadow: -24vmin 0 3.4010394937297947vmin currentColor;
}
.background span:nth-child(8) {
    color: #e23b03;
    top: 6%;
    left: 5%;
    animation-duration: 9s;
    animation-delay: -14s;
    transform-origin: 21vw 16vh;
    box-shadow: 24vmin 0 3.783591985477768vmin currentColor;
}
.background span:nth-child(9) {
    color: #db0a2a;
    top: 67%;
    left: 39%;
    animation-duration: 19s;
    animation-delay: -10s;
    transform-origin: 15vw -8vh;
    box-shadow: -24vmin 0 3.9571407352420733vmin currentColor;
}
.background span:nth-child(10) {
    color: #ef0148;
    top: 82%;
    left: 46%;
    animation-duration: 10s;
    animation-delay: -2s;
    transform-origin: 4vw 17vh;
    box-shadow: 24vmin 0 3.759437621108271vmin currentColor;
}
.background span:nth-child(11) {
    color: #e23b03;
    top: 25%;
    left: 78%;
    animation-duration: 10s;
    animation-delay: -5s;
    transform-origin: 9vw 12vh;
    box-shadow: -24vmin 0 3.9572753784603845vmin currentColor;
}
.background span:nth-child(12) {
    color: #db0a2a;
    top: 58%;
    left: 97%;
    animation-duration: 21s;
    animation-delay: -17s;
    transform-origin: -14vw 8vh;
    box-shadow: 24vmin 0 3.6059421302790846vmin currentColor;
}
.background span:nth-child(13) {
    color: #db0a2a;
    top: 74%;
    left: 4%;
    animation-duration: 23s;
    animation-delay: -15s;
    transform-origin: 23vw -17vh;
    box-shadow: 24vmin 0 3.695259738350418vmin currentColor;
}
.background span:nth-child(14) {
    color: #ef0148;
    top: 52%;
    left: 42%;
    animation-duration: 25s;
    animation-delay: -19s;
    transform-origin: 10vw -7vh;
    box-shadow: -24vmin 0 3.73894051739131vmin currentColor;
}
.background span:nth-child(15) {
    color: #e23b03;
    top: 69%;
    left: 66%;
    animation-duration: 17s;
    animation-delay: -9s;
    transform-origin: -12vw -10vh;
    box-shadow: 24vmin 0 3.047299563625905vmin currentColor;
}
.background span:nth-child(16) {
    color: #ef0148;
    top: 59%;
    left: 6%;
    animation-duration: 15s;
    animation-delay: -6s;
    transform-origin: 19vw -6vh;
    box-shadow: -24vmin 0 3.625317111733916vmin currentColor;
}
.background span:nth-child(17) {
    color: #db0a2a;
    top: 28%;
    left: 54%;
    animation-duration: 12s;
    animation-delay: -19s;
    transform-origin: 6vw 15vh;
    box-shadow: -24vmin 0 3.4178922453922933vmin currentColor;
}
.background span:nth-child(18) {
    color: #e23b03;
    top: 69%;
    left: 29%;
    animation-duration: 12s;
    animation-delay: -10s;
    transform-origin: 11vw -11vh;
    box-shadow: 24vmin 0 3.434740974983952vmin currentColor;
}
.background span:nth-child(19) {
    color: #db0a2a;
    top: 15%;
    left: 95%;
    animation-duration: 14s;
    animation-delay: -14s;
    transform-origin: 7vw -17vh;
    box-shadow: 24vmin 0 3.3796819322286904vmin currentColor;
}
.background span:nth-child(20) {
    color: #ef0148;
    top: 49%;
    left: 43%;
    animation-duration: 22s;
    animation-delay: -1s;
    transform-origin: -13vw 0vh;
    box-shadow: 24vmin 0 3.302033905826854vmin currentColor;
}
.background span:nth-child(21) {
    color: #e23b03;
    top: 7%;
    left: 49%;
    animation-duration: 11s;
    animation-delay: -4s;
    transform-origin: -11vw -14vh;
    box-shadow: 24vmin 0 3.5528575174612405vmin currentColor;
}
.background span:nth-child(22) {
    color: #db0a2a;
    top: 84%;
    left: 54%;
    animation-duration: 14s;
    animation-delay: -2s;
    transform-origin: -11vw -20vh;
    box-shadow: 24vmin 0 3.311161890039559vmin currentColor;
}
.background span:nth-child(23) {
    color: #e23b03;
    top: 71%;
    left: 91%;
    animation-duration: 23s;
    animation-delay: -9s;
    transform-origin: 2vw -17vh;
    box-shadow: 24vmin 0 3.186764783801273vmin currentColor;
}
.background span:nth-child(24) {
    color: #db0a2a;
    top: 52%;
    left: 19%;
    animation-duration: 14s;
    animation-delay: -19s;
    transform-origin: 25vw -12vh;
    box-shadow: -24vmin 0 3.7020928919989013vmin currentColor;
}
.background span:nth-child(25) {
    color: #db0a2a;
    top: 13%;
    left: 62%;
    animation-duration: 6s;
    animation-delay: -19s;
    transform-origin: 8vw 10vh;
    box-shadow: -24vmin 0 3.6923845598463068vmin currentColor;
}
.background span:nth-child(26) {
    color: #db0a2a;
    top: 80%;
    left: 65%;
    animation-duration: 7s;
    animation-delay: -8s;
    transform-origin: 12vw -18vh;
    box-shadow: 24vmin 0 3.3340613607405336vmin currentColor;
}
.background span:nth-child(27) {
    color: #ef0148;
    top: 99%;
    left: 78%;
    animation-duration: 14s;
    animation-delay: -3s;
    transform-origin: -9vw 10vh;
    box-shadow: 24vmin 0 3.313430986996916vmin currentColor;
}
.background span:nth-child(28) {
    color: #db0a2a;
    top: 43%;
    left: 23%;
    animation-duration: 7s;
    animation-delay: -14s;
    transform-origin: 16vw 14vh;
    box-shadow: -24vmin 0 3.9744347269008666vmin currentColor;
}
.background span:nth-child(29) {
    color: #ef0148;
    top: 98%;
    left: 21%;
    animation-duration: 20s;
    animation-delay: -7s;
    transform-origin: -16vw -16vh;
    box-shadow: -24vmin 0 3.143407242934314vmin currentColor;
}
.background span:nth-child(30) {
    color: #e23b03;
    top: 73%;
    left: 55%;
    animation-duration: 10s;
    animation-delay: -11s;
    transform-origin: 15vw 16vh;
    box-shadow: -24vmin 0 3.4255488338415714vmin currentColor;
}
.background span:nth-child(31) {
    color: #db0a2a;
    top: 18%;
    left: 32%;
    animation-duration: 7s;
    animation-delay: -18s;
    transform-origin: -7vw -9vh;
    box-shadow: -24vmin 0 3.417448222335527vmin currentColor;
}
.background span:nth-child(32) {
    color: #db0a2a;
    top: 22%;
    left: 42%;
    animation-duration: 12s;
    animation-delay: -3s;
    transform-origin: 19vw 15vh;
    box-shadow: 24vmin 0 3.9679516395467944vmin currentColor;
}
.background span:nth-child(33) {
    color: #db0a2a;
    top: 10%;
    left: 26%;
    animation-duration: 22s;
    animation-delay: -17s;
    transform-origin: -9vw -8vh;
    box-shadow: -24vmin 0 3.1329314858140433vmin currentColor;
}
.background span:nth-child(34) {
    color: #db0a2a;
    top: 79%;
    left: 46%;
    animation-duration: 17s;
    animation-delay: -5s;
    transform-origin: 7vw 14vh;
    box-shadow: 24vmin 0 3.6373979767406626vmin currentColor;
}
.background span:nth-child(35) {
    color: #db0a2a;
    top: 63%;
    left: 60%;
    animation-duration: 25s;
    animation-delay: -16s;
    transform-origin: 6vw -23vh;
    box-shadow: 24vmin 0 3.841631324656799vmin currentColor;
}
.background span:nth-child(36) {
    color: #ef0148;
    top: 75%;
    left: 26%;
    animation-duration: 14s;
    animation-delay: -16s;
    transform-origin: 20vw 15vh;
    box-shadow: -24vmin 0 3.9738706133226525vmin currentColor;
}
.background span:nth-child(37) {
    color: #e23b03;
    top: 73%;
    left: 2%;
    animation-duration: 15s;
    animation-delay: -2s;
    transform-origin: -20vw 16vh;
    box-shadow: 24vmin 0 3.7202456251633342vmin currentColor;
}
.background span:nth-child(38) {
    color: #db0a2a;
    top: 79%;
    left: 1%;
    animation-duration: 18s;
    animation-delay: -6s;
    transform-origin: -2vw 16vh;
    box-shadow: -24vmin 0 3.8456920968672588vmin currentColor;
}
.background span:nth-child(39) {
    color: #e23b03;
    top: 61%;
    left: 8%;
    animation-duration: 11s;
    animation-delay: -16s;
    transform-origin: 20vw -23vh;
    box-shadow: 24vmin 0 3.6526422807921186vmin currentColor;
}
.background span:nth-child(40) {
    color: #ef0148;
    top: 53%;
    left: 66%;
    animation-duration: 24s;
    animation-delay: -11s;
    transform-origin: 22vw -6vh;
    box-shadow: 24vmin 0 3.395196415624116vmin currentColor;
}
.background span:nth-child(41) {
    color: #ef0148;
    top: 19%;
    left: 61%;
    animation-duration: 18s;
    animation-delay: -7s;
    transform-origin: -4vw -3vh;
    box-shadow: -24vmin 0 3.596120193081557vmin currentColor;
}
.background span:nth-child(42) {
    color: #db0a2a;
    top: 31%;
    left: 58%;
    animation-duration: 12s;
    animation-delay: -19s;
    transform-origin: -12vw 14vh;
    box-shadow: 24vmin 0 3.607460867981278vmin currentColor;
}

              
            
!

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,
      }
    })
    .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