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

109
Views
Tratar con el valor cambiante de ScrollY

Soy nuevo en desarrollo web y javascript, así que no juzgues esta pregunta.

Tengo un pie de página que quiero mostrar solo cuando los usuarios de mi sitio web se desplazan hasta el final.

He hecho esto en javascript y funciona bien, pero me pregunto si hay una manera de obtener en javascript el valor scrollY para la parte inferior de diferentes tamaños de pantalla. Por ejemplo, el scrollY no es el mismo en móviles y portátiles.

 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 answers
Answer question

0

Debe verificar window.innerHeight y window.pageYOffset si son mayores que offsetHeight del documento. Esto mostrará el pie de página mientras está en la parte inferior.

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