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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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 id="scrollbar">
  <div class="wrapper">
    <div class="item">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Necessitatibus, temporibus esse magni illum eos natus ipsum minus? Quis excepturi voluptates atque dolorum minus eligendi! Omnis minima magni recusandae ex dignissimos.</div>
    <div class="item">Eaque ullam illum nobis deleniti mollitia unde, sed, nemo ipsa ratione ex, dicta aliquam voluptates! Odio vitae eum nobis dignissimos sunt ipsum repellendus totam optio distinctio. Laborum suscipit quia aperiam.</div>
    <div class="item">Animi, porro molestias? Reiciendis dolor aspernatur ab quos nulla impedit, dolores ullam hic commodi nobis nam. Dolorem expedita laudantium dignissimos nobis a. Dolorem, unde quidem. Tempora et a quibusdam inventore!</div>
    <div class="item">Labore, unde amet! Alias delectus hic laboriosam et dolorum? Saepe, dicta eaque? Veniam eos blanditiis neque. Officia et nostrum, tempore modi quo praesentium aspernatur vero dolor, ipsa unde perspiciatis minima.</div>
    <div class="item">Quaerat error dolorem aspernatur magni dicta ut consequuntur maxime tempore. Animi odio eos quod culpa nulla consectetur? Aperiam ipsam ducimus delectus reprehenderit unde, non laborum voluptate laboriosam, officiis at ea!</div>
    <div class="item">Rem nobis facere provident magni minima iste commodi aliquam harum? Facere error quos cumque perspiciatis voluptatibus deserunt maiores, fugiat sunt sit ab inventore natus saepe, eveniet alias ipsam placeat voluptas!</div>
    <div class="item">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Necessitatibus, temporibus esse magni illum eos natus ipsum minus? Quis excepturi voluptates atque dolorum minus eligendi! Omnis minima magni recusandae ex dignissimos.</div>
    <div class="item">Magnam eveniet inventore assumenda ullam. At saepe voluptatibus sed dicta reiciendis, excepturi nisi perferendis, accusantium est suscipit tempora dolorum praesentium cupiditate doloribus non? Sint numquam recusandae dolore quis esse ea?</div>
    <div class="item">Temporibus cum dolor minima consequatur esse veritatis enim nemo cupiditate laborum doloribus reiciendis perferendis, quas fugit earum rerum, at beatae alias amet aspernatur dolorem dolore error commodi. Perspiciatis, reiciendis amet!</div>
    <div class="item">Vitae, tenetur beatae error corrupti odit expedita quisquam commodi ea aspernatur aliquid, eveniet reprehenderit sequi, similique maiores praesentium quam! Optio tenetur saepe unde voluptatem minus tempora maxime temporibus ducimus ullam!</div>
    <div class="item">Dolor, dolorum beatae accusamus obcaecati, distinctio similique quibusdam corporis, deleniti praesentium recusandae blanditiis! Vel sapiente quisquam sed dignissimos error, ea sit quaerat alias aperiam illo non numquam voluptatibus architecto? Impedit?</div>
    <div class="item">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Necessitatibus, temporibus esse magni illum eos natus ipsum minus? Quis excepturi voluptates atque dolorum minus eligendi! Omnis minima magni recusandae ex dignissimos.</div>
  </div>
</div>
              
            
!

CSS

              
                *,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  height: 100vh;
  overflow: hidden;
  font-family: 'PT Sans', sans-serif;
  color: #444;
  height: 100vh;
}

#scrollbar {
  height: 100vh;
  background: #eee;
}

.scrollbar-track-x {
  height: 1px!important;
  bottom: 40px!important;
  margin: 0 auto!important;
  left: 0!important;
  right: 0!important;
  background: rgba(0, 0, 0, .06)!important;
  
  .scrollbar-thumb {
    height: 3px;
    top: -1px;
    background: rgba(0, 0, 0, .1);
  }
}

.wrapper {
  display: flex;
  position: relative;
  z-index: 1;
  counter-reset: item;
  height: 100vh;
  
  .item {
    position: relative;
    padding: 150px 80px;
    flex: 0 0 500px;
    height: 100vh;
    display: flex;
    align-items: center;
    line-height: 1.7; 
    user-select: none;
    border-right: 1px solid rgba(0, 0, 0, .06);
    
    &:before {
      counter-increment: item;
      content: counter(item);
      font-size: 100px;
      opacity: .13;
      font-weight: bold;
      position: absolute;
      z-index: -1;
      transform: translate(-30px, -50px);
      font-family: 'Libre Baskerville', serif;
      line-height: 1;
    }
    
    &:nth-child(2n+2) {
      align-items: flex-start;
    }
    
    &:nth-child(4n+4) {
      align-items: flex-end;
    }
  }
}

.pagination {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  white-space: none;
  display: flex;
  
  button {
    text-indent: -9999px;
    outline: none;
    width: 20px;
    height: 20px;
    border: none;
    position: relative;
    background: none;
    padding: 0;
    font-size: 0;
    
    &:before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      border: 1px solid #aaa;
      width: 7px;
      height: 7px;
      border-radius: 50%;
      box-shadow: inset 0 0 0 1px #eee;
      transition: background .2s ease-in-out;
    }
    
    &.active {
      &:before {
        background: #111;
      }
    }
  }
}
              
            
!

JS

              
                class HorizontalScrollPlugin extends Scrollbar.ScrollbarPlugin {
  static pluginName = 'horizontalScroll';

  transformDelta(delta, fromEvent) {
    if (!/wheel/.test(fromEvent.type)) {
      return delta;
    }
    
    // @see: https://github.com/idiotWu/smooth-scrollbar/issues/181
    
    const { x, y } = delta; 

    return {
      y: 0,
      x: Math.abs(x) > Math.abs(y) ? x : y,
      // x: Math.sign(x || y) * Math.sqrt(x*x + y*y),
    };
  }
}

Scrollbar.use(HorizontalScrollPlugin, OverscrollPlugin /* you forgot this */);

// the following is forked from https://codepen.io/supah/pen/vvNmOr

/*--------------------
Wheel Option
-------------------*/
let option = {
  x: 0,
  speed: 1.5,
  limit: 2,
  time: 0.3,
};


/*--------------------
Init Scrollbar
-------------------*/
const scrollbar =  Scrollbar.init(document.querySelector('#scrollbar'), {
  overscrollEffect: 'bounce',
  alwaysShowTracks: true
});
const listener = (status) => {
  console.log('scrollbar', status.offset.x)
  active = parseInt(status.offset.x / 500);
  
  bullets.forEach(b => {b.classList.remove('active')});
  bullets[active].classList.add('active');
};
scrollbar.addListener(listener);


/*--------------------
Pagination
-------------------*/
let active = 0;
let pag, bullets;

const pagination = () => {
  const items = document.querySelectorAll('.item');
  pag = document.createElement('div');
  pag.classList.add('pagination');
  items.forEach((item, i) => {
    const bullet = document.createElement('button');
    bullet.classList.add('bullet');
    bullet.innerHTML = i
    pag.appendChild(bullet)
  });
  document.getElementById('scrollbar').appendChild(pag);
  bullets = document.querySelectorAll('.bullet');

  bullets.forEach((b, i) => {
    b.addEventListener('click', el => {
      bullets.forEach(el => {el.classList.remove('active')})
      el.target.classList.add('active');
      const i = parseInt(el.target.innerHTML);
      active = i;

      let x = 500 * i;
      if (x > scrollbar.limit.x) {
        x = scrollbar.limit.x
      }

      TweenMax.to(option, 1, {
        x: x,
        ease: Power4.easeOut,
        onUpdate: () => {
          window.console.log('option', option.x)
          scrollbar.scrollTo(option.x, 0, 0);
        }
      })
    });
  });
}
pagination();

/*--------------------
Mousewheel
-------------------*/

/*

const horizontalScroll = (e) => {
  const y = parseInt(e.deltaY * option.speed);
  let x = scrollbar.offset.x + y;
  x = x < 0 ? 0 : x > scrollbar.limit.x ? scrollbar.limit.x : x;

  TweenMax.to(option, option.time, {
    x: x,
    onUpdate: () => {
      window.console.log('option', option.x)
      scrollbar.scrollTo(option.x, 0, 0);
    }
  })
};
document.querySelector('.wrapper').addEventListener('mousewheel', (e) => {
  horizontalScroll(e)
});

*/
              
            
!
999px

Console