Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda