When you glance at the scroll bar on your screen, it may seem like the direction is changing. However, what's actually happening is that during the horizontal movement, the area being "scrolled" becomes fixed in position and fills the entire screen. As you continue scrolling downwards, it appears to shift leftwards, creating the illusion of horizontal scrolling even though there isn't any.
For a simple demonstration, here's an example without the smooth transition from vertical to horizontal scrolling:
document.onscroll = () => {
// adjust for the difference between window height and width
let percentScrolled = window.pageYOffset / window.innerHeight;
let toScroll = percentScrolled * window.innerWidth;
// scroll horizontally
document.getElementById("scroll").style.left = "-" + toScroll + "px";
}
body {
width: 100vw;
height: 500vh;
overflow-x: hidden;
}
div {
width: 500vw;
position: fixed;
}
<div id = "scroll">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ac leo nulla. Donec volutpat consequat elit ut tincidunt. Proin id purus sed nulla lacinia eleifend sed porttitor neque. Vestibulum volutpat porta ex. Aenean accumsan metus eu euismod semper. Phasellus viverra tortor eget enim ultrices, quis dignissim lectus posuere. Nullam turpis nisl, fringilla gravida interdum nec, semper et tellus. Etiam vitae rutrum ligula. Nulla lobortis massa odio, id tempor leo dictum sit amet.
Nulla ut porta orci. Maecenas pulvinar est ac est accumsan, non consequat augue lobortis. Morbi semper sollicitudin eros, sit amet lacinia nulla varius a. Nam dignissim faucibus risus, eleifend tincidunt dolor scelerisque a. Quisque tempus, quam efficitur feugiat laoreet, sapien eros aliquam erat, auctor feugiat lacus ipsum id nisl. In nisi urna, laoreet eget pulvinar dignissim, maximus laoreet augue. Vivamus euismod mauris nec felis posuere, eu maximus ante volutpat. Integer porttitor urna quis vehicula feugiat. Integer justo nibh, rutrum pulvinar massa quis, molestie pretium ipsum.</div>