Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Change Scroll Direction Mid Page and then Revert Back

I came across this page and I was really impressed on how the scroll direction changed mid page to horizontal and then reverted back to vertical.

I don't have the slightest idea how that is done. Can someone fill me in?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you look at your scroll bar, the direction isn't actually being changed. During the horizontal portion, the "scrolling" area gets position: fixed and fills the screen, then it is shifted towards the left as you continue scrolling down. This gives the illusion of horizontal scrolling when there is none.

Here's an example, though without the transition between vertical and 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>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!