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

319
Views
¿Cómo hacer una animación horizontal que funcione sincrónicamente con el desplazamiento? (JS)

¿Puede decirme cómo hacer una animación horizontal que funcione sincrónicamente con el desplazamiento?

Hice una muestra, pero hay un inconveniente: el evento tiene un punto de inicio y un final, y quiero hacer una animación permanente:

 const targetTx = document.querySelector('h1'); function animateTx() { if (document.documentElement.scrollTop > 50) { targetTx.classList.add('active'); } else { targetTx.classList.remove('active'); } } window.onscroll = function() {animateTx()};
 section { height: 600px; border-bottom: solid 1px #000; overflow: hidden; } h1 { display: block; font-size: 10rem; color: #999; white-space: nowrap; transition: 0.5s; } h1.active { margin-left: -50%; transition: 0.5s; }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <section> <h1>TEST TEXT</h1> </section> <section></section> </body> </html>

¡Gracias de antemano!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usa animaciones css :

 const targetTx = document.querySelector('h1'); function animateTx() { if (document.documentElement.scrollTop > 50) { targetTx.classList.add('slide-anim'); } else { targetTx.classList.remove('slide-anim'); } } window.onscroll = function() {animateTx()};
 section { height: 600px; border-bottom: solid 1px #000; overflow: hidden; } h1 { display: block; font-size: 10rem; color: #999; white-space: nowrap; } .slide-anim { animation: slide 3s linear infinite; } @keyframes slide { 0% { margin-left: 0; } 25% { margin-left: -50%; } 50% { margin-left: 0%; } 75% { margin-left: 50%; } 100% { margin-left: 0; } }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <section> <h1>TEST TEXT</h1> </section> <section></section> </body> </html>

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!