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

251
Views
How to log window.scrollY value on console with next js?

For some reason my ScrollToTop component is not working as expected in my app. I have tried to debug the matter in all ways that i know but i cannot figure out why the component do not log value of scrollY as expected. I tried to move the snippet below in other component of my app but same result. I tried to call the toggleVisibilty function but it only log 0 once then nothing else. Can someone tell me what can cause such error, please? thanks

 const toggleVisibility = () => {
      console.log(window.scrollY)
      // window.pageYOffset >= 300 ?
      // setisVisible(true) :
    
      // setisVisible(false)
      // console.log(window.pageYOffset)      
    };
    //toggleVisibility()
    // const scrollToTop = () => {
    //   window.scrollTo({
    //       top:0,
    //       behavior: "smooth",
    //   });
    // };
    
    useEffect(() => {
      window.addEventListener('scroll', toggleVisibility, {passive: true});
      return () => window.removeEventListener('scroll', toggleVisibility);
      
    
    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found what was my mistake. my html and body had a height property rather than a min-height in my css file. When changed this it worked fine.

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!