title: Replace vertical scroll by horizontal scroll vanilla javascript
body: <p>I want to disable and replace the vertical scroll with horizontal one in Vanilla JavaScript. I am blocked when I try to replace my scroll values. I trust there is a simple simple (really simple) solution to that !</p>
  
  <pre><code>/* We define our function  */
  function replaceVerticalScrollByHorizontal() {
    let scrollX = window.scrollX; /* Horizontal ➡️ */
    let scrollY = window.scrollY; /* Vertical ⬇️ */
    console.log({scrollX, scrollY});
  
    if (scrollY !== 0) {
      /* If there is a changement in verticalScroll  ⬇️ */
      const tempScrollY = scrollY; /* We create a temporary var to stock our scrollY value */
      scrollX = scrollY; /* Horizontal = Vertical */
      scrollY = 0; /* We reset the vertical because we don't want any vertical scroll */
      window.scrollTo(scrollX, scrollY); /* We scroll to our value */
      scrollY = tempScrollY; /* We replace the value of our vertical var with the temporary one */
    }
    /* If no verticalScroll changement, exit of this function  ⬇️ */
    return;
  }
  
  /* Listener on window once we start scrolling, we run our function  */
  window.addEventListener('scroll', replaceVerticalScrollByHorizontal);
  </code></pre>
  
  <p>There is a little jsfiddle with my problem: <a href="https://jsfiddle.net/zynj64m7/2/" rel="nofollow noreferrer">https://jsfiddle.net/zynj64m7/2/</a></p>