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

122
Views
Turn both vertical and horizontal scrolling events into horizontal scrolling with HTML & JS

I'm developing a horizontal-scrolling portfolio website using React.js. Essentially it's just a sideways picture gallery that you can easily scroll through using the trackpad.

Currently it all fits into a big container that uses:

  overflow-x: scroll;
  overflow-y: none;

  -ms-overflow-style: none;
  scrollbar-width: none;

Recently I realized that this site would be unusable for people who use a mouse and a desktop computer because as far as I know the mouse can't scroll sideways unless there's a scrollbar (which I don't want to add for aesthetic reasons) or some kind of y-to-x scroll conversion.

Now I'm trying to implement this scroll conversion in case users are unable to scroll horizontally. I found this solution but couldn't get it to work correctly:

const scroller = document.getElementById('pageContainer');

window.addEventListener('wheel', e => {
   scroller.scrollLeft += e.deltaY;
});

The snippet above effectively breaks both ways of scrolling for me. The vertical scroll scrolls my page container to the left very slightly, about 1/12th the speed of normal scrolling if not less. The previously-working horizontal scroll now seems to "fight" with the other scroll and jerk the page into the correct direction or stutter it over.

What am I missing? What's the cleanest way to achieve this?

Ideally I'd like the scrolling to move side to side in a sinusoidal motion if I'm "scrolling" in a circular motion.

EDIT:

I've found a codepen that achieves the desired behaviour and implemented it: https://codepen.io/aaaaaaaz/pen/OJpXBXM

It still didn't work but it gave me the idea to try an disable scroll-behavior: smooth; in my css – I was using it for buttons that would programmatically scroll you to further parts of the page faster.

The new question now is, is there any way for these things to work in tandem?

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

0

PLease add height and width in you div style where you want add horizontal-scrolling on portfolio website

#content {
  height: 100%;
  width: 9000px;
}
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!