DEV Community

Discussion on: Divert Vertical Scroll To The Side ↔️

Collapse
 
mr21 profile image
Thomas Tortorini

You have to let the default behaviour for the user who scroll with shift to not lose the scroll inertia

scrollableElement.addEventListener('wheel', (ev) => {
  if (!ev.shiftKey) {
    ev.preventDefault();
    scrollableElement.scrollLeft += ev.deltaY + ev.deltaX;
  }
});

Also when you scroll horizontally on a laptop trackpad, the shiftKey will be set to true.