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

94
Visualizações
React Force horizontal scrolling as vertical scroll when reaching element view

I've been trying to achieve this effect of default horizontal scrolling when reaching element's view. I still could not find some decent way to implement it correctly, for now I was only able to achieve it with pure CSS (the problem is - it doesn't scrolled horizontal correctly, I need to click on the element so it will be aware I'm in the right view. This is my code for now -

::-webkit-scrollbar {
      width: 1px;
      height: 1px;
    }

    ::-webkit-scrollbar-button {
      width: 1px;
      height: 1px;
    }


    .test {
      position: absolute;
      display: block;
      top: 0;
      left: 0;
      width: calc(250px + 1px);
      max-height: 750px;
      margin: 0;
      padding-top: 1px;
      background: #abc;
      overflow-y: auto;
      overflow-x: hidden;
      transform: rotate(-90deg) translateY(-250px);
      transform-origin: right top;
      padding: 250px 0 0 0;
    }

    .test div {
      display: block;
      padding: 5px;
      background: #cab;
      transform: rotate(90deg);
      transform-origin: right top;
      width: 250px;
      height: 250px;
      margin: 10px 0;
    }
<div class="test">
      <div>div</div>
      <div>div</div>
      <div>div</div>
      <div>div</div>
      <div>div</div>
      <div>div</div>
      <div>div</div>
      <div>div</div>
    </div>

I'd love to know if there is any way to make the scrolling automatically start horizontally as I reach the view, and if that's not possible I'd love to know how would you implement it with JS in React. Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm a little confused about the wording of this question - by "default horizontal scrolling", do you mean as the user scrolls down it scrolls horizontally instead?

If that's the case you'll probably want to set up an event handler to detect scroll, and have it call window.scrollBy()

window.addEventListener('scroll', handleScroll);

handleScroll(e){
   window.ScrollBy(e.deltaY, 0);
}

link to scrollBy method

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