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

75
Views
Animar texto con matriz

Estoy tratando de animar texto con javascript usando una matriz con intervalos de tiempo, por ejemplo, t te tex text , quiero que pase de 0 a 21 y viceversa y no estoy completamente seguro de cómo hacerlo. ¡Cualquier ayuda es muy apreciada!

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

0

Concepto general:
Debe actualizar la salida de la cadena cada marca con el siguiente valor hasta que la cadena completa sea visible. El intervalo de tic define qué tan rápida es la animación.

Una de las posibles realizaciones a continuación:

 // Wait [ms] milliseconds const Delay = ms => new Promise(r => setTimeout(r, ms)); // Main function const main = async () => { const p = document.querySelector('p'); // String you wanna animate const targetText = 'Hello there!'; // Tick interval const tick = 60; // Iterating through string for (let i = 1; i <= targetText.length; i++) { // Set new value p.innerHTML = ('&nbsp;'.repeat(targetText.length - i) + targetText.slice(-i)); // Wait for a next tick await Delay(tick); } } main();
 p { font-family: Monospace; }
 <p></p>

Aquí están:
&nbsp; - el espacio será visible dentro de .innerHTML() ; tick - intervalo entre cuadros de animación (en milisegundos);

Referencias: .slice() , .repeat() .

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!