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

97
Visualizações
jump to next view while scrolling in reactjs

I'm trying to implement a scroll effect where I have a slide-like web page, and I want make the scroll bar jump to the next slide/section while scrolling -if scrolling up jump to the above section otherwise jump to the section below the current section-. the code below is my attempt, I used "jump.js" to jump into the target section, and in order to detect the scrolling direction I use "y > window.scrollY" condition, but the problem is is that a single scroll trigger the function over 200 times what makes it enter an endless loop. any solution of the problem ?

const [y, setY] = useState(0);
let sectionN = 1
const handleNavigation = (e) => {
    const window = e.currentTarget;
        if (y > window.scrollY && sectionN > 1) {
            sectionN -= 1;
            const targetSection = `.section-${sectionN}`;
            jump(targetSection);
        } else if (y < window.scrollY && sectionN < 6) {
            sectionN += 1;
            const targetSection = `.section-${sectionN}`;
            jump(targetSection);
        }
        setY(window.scrollY);
  };
about 4 years ago · Juan Pablo Isaza
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