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

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="wrapper">

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">01</div>
          <img src="https://picsum.photos/600/800?random=1">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">02</div>
          <img src="https://picsum.photos/600/800?random=2">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">03</div>
          <img src="https://picsum.photos/600/800?random=3">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">04</div>
          <img src="https://picsum.photos/600/800?random=4">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">05</div>
          <img src="https://picsum.photos/600/800?random=5">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">06</div>
          <img src="https://picsum.photos/600/800?random=6">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">07</div>
          <img src="https://picsum.photos/600/800?random=7">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">08</div>
          <img src="https://picsum.photos/600/800?random=8">
        </a>
      
    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">09</div>
          <img src="https://picsum.photos/600/800?random=9">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">10</div>
          <img src="https://picsum.photos/600/800?random=10">
        </a>

    </section>

    <section class="section">

        <a href="" class="img-gradient">
          <div class="section--text">11</div>
          <img src="https://picsum.photos/600/800?random=11">
        </a>

    </section>

</div>

<div class="navi navi--prev">Prev</div>
<div class="navi navi--next">Next</div>
              
            
!

CSS

              
                ::-webkit-scrollbar {
  display: none;
}

@import url("https://fonts.googleapis.com/css2?family=Montserrat:[email protected];500;700;800;900&display=swap");

body {
  font-family: "Monserrat", sans-serif, Arial;
}
.wrapper {
  display: flex;
  flex-wrap: nowrap;
  position: fixed;
}

.section {
  display: flex;
  flex-shrink: 0;
  height: 100vh;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  width: 33.33vw;
  font-size: 30px;

  img {
    height: 100vh;
  }

  .img-gradient {
    display: inline-block;
    height: 100%;

    &:after {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      display: inline-block;
      background: -moz-linear-gradient(
        top,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 0, 0, 1) 100%
      ); /* FF3.6-15 */
      background: -webkit-linear-gradient(
        top,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 0, 0, 1) 100%
      ); /* Chrome10-25,Safari5.1-6 */
      background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 0, 0, 1) 100%
      ); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
    }
  }

  &--text {
    position: absolute;
    top: 30%;
    left: 20%;
    width: 100%;
    z-index: 99;
    color: #fff;
    font-size: 200px;
    opacity: 0.5;

    h2 {
      font-weight: 700;
      letter-spacing: -0.05em;

      span {
        opacity: 0.75;
        font-weight: 400;
      }
    }

    p {
      font-size: 14px;
      opacity: 0;
    }
  }
}

.navi {
  position: fixed;
  bottom: 2%;
  border-radius: 50%;
  color: #fff;
  width: 45px;
  height: 45px;
  cursor: pointer;
  z-index: 4;
  opacity: 1;
}

.navi--prev {
  left: 2.188rem;
}

.navi--next {
  right: 2.188rem;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);
gsap.registerPlugin(ScrollToPlugin);

/* SCROLLER */

var scroller = document.querySelector(".wrapper");

var sections = document.querySelectorAll(".section");
var numSections = sections.length;

let scrollWidth;
function createScroller() {
  scrollWidth = scroller.offsetWidth - innerWidth;
  console.log ("scroller width = " + scroller.offsetWidth);
  ScrollTrigger.addEventListener("refreshInit", () => {
    scrollWidth = scroller.offsetWidth - innerWidth;
    gsap.set(document.body, {height: scrollWidth + innerHeight});
  });
}

createScroller();

scroll_tl = gsap.timeline();

scroll_tl.to(scroller, {
    x: () => -scrollWidth,
    ease: "none",
    scrollTrigger: {
      start: 0,
      end: "bottom bottom",
      scrub: 0.75,
      invalidateOnRefresh: true,
      onUpdate: trigger => console.log(trigger.progress)
    }
});

/* NAV */

// use to position scroller
let navWidth = 0;
// set width of scroller minus width of screen to get moveable width
let maxScrollerWidth = scroller.offsetWidth - innerWidth;

// let wrapper_getter = gsap.getProperty(".wrapper");
// var wrapper_y = wrapper_getter("y");
// console.log ("wrapper_y after init = " + wrapper_y);

function slideAnim(e) {
  e.preventDefault();
  nav_tl = gsap.timeline();
  
  // NEXT
  if( $(this).hasClass("navi--next") ){
     // if current postion + screen width is less than the moveable width
    if ((navWidth + innerWidth) < maxScrollerWidth) {
     // move by width of screen 
      navWidth += innerWidth;
    } else {
      // otherwise we must be near the end so just move to the end
      navWidth = maxScrollerWidth;
    }
    //console.log("navWidth = " + navWidth);
  }
  
  // PREV
  if( $(this).hasClass("navi--prev") ){
    // if current position - screen width is more than 0 we must be off screen
    if ((navWidth - innerWidth) > 0 ) {
      // current position = current position - screen width
      navWidth -= innerWidth;
    } else {
      // back to start
      navWidth = 0;
    }
  }
  
  // TimeLine
  
  nav_tl.to(window, {
    duration: 2, 
    ease:"power3.out",
    scrollTo: navWidth
  });
  
}
  
document.querySelector(".navi--prev").addEventListener("click", slideAnim);
document.querySelector(".navi--next").addEventListener("click", slideAnim);
              
            
!
999px

Console