Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
Deal with ScrollY changing value

I'm new to web development and javascript so please don't judge this question.

I have a footer that I want to show only when my website users scroll to the bottom.

I have done this in javascript and it works fine but I am wondering if there is a way to get in javascript the scrollY value for the bottom of different screen sizes. For example, the scrollY is not the same on mobile and laptops.

const footerUp = document.querySelector('.footer');

/*Show footer only when scroll to the bottom*/
window.addEventListener('scroll', () => {
  if (window.scrollY >=600) {
    footerUp.style.bottom = 0;
  } else{
    footerUp.style.bottom = '-22rem';
  }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should check window.innerHeight and window.pageYOffset if they're greater than document's offsetHeight. This will show the footer while at the bottom

const footerUp = document.querySelector('.footer');

/*Show footer only when scroll to the bottom*/
window.addEventListener('scroll', () => {
  if (window.innerHeight + window.pageYOffset >= document.body.offsetHeight) { // <--- here
    footerUp.style.bottom = 0;
  } else{
    footerUp.style.bottom = '-22rem';
  }
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda