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

309
Views
Cómo revertir el efecto 'ScrollY' al desplazarse hacia arriba

Estoy tratando de hacer que la línea se extienda cuando alguien se desplaza hacia abajo y se encoja cuando alguien se desplaza hacia arriba. No estoy seguro de qué es exactamente lo que falta para el JavaScript.

https://jsfiddle.net/nqu2L4mc/

JavaScript

 // Timeline Begins "use strict"; function qs(selector, all = false) { return all ? document.querySelectorAll(selector) : document.querySelector(selector); } const sections = qs('.timeline_section', true); const timeline = qs('.timeline'); const line = qs('.timeline_line'); line.style.bottom = `calc(100%)`; let prevScrollY = window.scrollY; let up, down; let full = false; let set = 0; const targetY = window.innerHeight * .8; function scrollHandler(e) { const { scrollY } = window; up = scrollY < prevScrollY; down = !up; const timelineRect = timeline.getBoundingClientRect(); const lineRect = line.getBoundingClientRect(); // const lineHeight = lineRect.bottom - lineRect.top; const dist = targetY - timelineRect.top; console.log(dist); if (down && !full) { set = Math.max(set, dist); line.style.bottom = `calc(100% - ${set}px)`; } if (dist > timeline.offsetHeight + 50 && !full) { full = true; line.style.bottom = `-50px`; } sections.forEach(item => { // console.log(item); const rect = item.getBoundingClientRect(); // console.log(rect); if (rect.top + item.offsetHeight / 5 < targetY) { item.classList.add('show-me'); } }); // console.log(up, down); prevScrollY = window.scrollY; } scrollHandler(); line.style.display = 'block'; window.addEventListener('scroll', scrollHandler); // Timeline Ends

Sería genial si alguien pudiera editar el código directamente.

Gracias por adelantado

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!