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

98
Views
si la condición lógica pageYoffset >= (element.offsetTop - element.clientHeight / 3)

No puedo entender la lógica pageYoffset >= (element.offsetTop - element.clientHeight / 3) de la declaración if .
Soy un principiante. Sé lo que es offsetTop , clientHeight y pageYOffset que no entiendo las matemáticas detrás de esto. Por favor ayuda.

Aquí está mi código:

 const sections document.querySelectorAll('section'); const navLi = document.querySelectorAll('nav .container u1 li'); window.addEventlistener ('scroll', ()=> { let current = ''; sections.forEach( section => { const sectionTop = section.offsetTop; const sectionHeight = section.clientHeight; if(pageYOffset >= (sectionTop - sectionHeight / 3)){ current = section.getAttribute('id'); }) navLi.forEach( li => { li.classList.remove('active'); if(li.classList.contains(current)){ li.classList.add('active') }) })
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!