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

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

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 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