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

95
Views
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
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!