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

126
Views
¿Cómo aplicaría una animación de desaparición gradual a cada uno de los íconos en mi menú dentro de un bucle for?

Actualmente estoy trabajando en una animación en la que hay un retraso entre cada uno de los íconos cuando se desvanece. La animación de desvanecimiento funciona bien, pero solo en el primer ícono y no estoy seguro de por qué es así. ¿Alguien podría señalar el error que estoy cometiendo?

Código JavaScript:

 function closeHorizontalWindow() { const delay = 150; const reasons = ['btnReady', 'btnNotReady', 'btnBreak', 'btnEmail', 'btnLunch', 'btnComfortBreak', 'btnMeeting', 'btnChat'] for (let i = 0; i < reasons.length; i++) { document.getElementById(reasons[i]).style.animation = `reasonsfadeout 0.45s ease-out forwards ${delay}ms` delay+=150 }

Código CSS:

 @keyframes reasonsfadeout { from{opacity: 1; } to {opacity: 0; } }

}

Gracias

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

0

Puede usar un intervalo para iterar en lugar de un bucle for regular.

 function closeHorizontalWindow() { const delay = 150; const reasons = ['btnReady', 'btnNotReady', 'btnBreak', 'btnEmail', 'btnLunch', 'btnComfortBreak', 'btnMeeting', 'btnChat'] let i = 0; const interval = setInterval(function(){ document.getElementById(reasons[i]).style.animation = `reasonsfadeout 0.45s ease-out forwards ${delay}ms`; i++; if(i>=reasons.length){ clearInterval(interval); } }, delay); }
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!