Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
JS animation Loop Transitions
var i = 1; 
const title = document.getElementById("display-heading");
var texts = [
    "Karibu",
    "Bienvenido",
      "স্বাগতম।",
      "Willkommen",
      "أهلا بك",
      "Bienvenue"
];

title.textContent = texts[0];

var loop = setInterval(function() {
    title.textContent = texts[i];
    i = (i+1) % texts.length; // Allows the array to loop
}, 1000);

How would I add a fade in/slow down the transition?

https://codepen.io/elliebrayton/pen/vYJBOBP

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is a little discrepancy between the CSS and the HTML: the HTML has an id attribute with name "display-heading", while the CSS defines attributes for a class with that name.

You can get the fading going by changing the opacity.

Here is a runnable snippet:

const title = document.getElementById("display-heading");

var texts = [
    "Karibu",
    "Bienvenido",
    "স্বাগতম।",
    "Willkommen",
    "أهلا بك",
    "Bienvenue"
];

title.addEventListener("transitionend", loop);

function loop() {
    if (title.style.opacity != "1") {
        texts.push(title.textContent = texts.shift());
        title.style.opacity = 1;
    } else {
        setTimeout(() => title.style.opacity = 0, 500);
    }
}

setTimeout(loop);
#display-heading{
  font-size: 30px;
  transition: 0.5s opacity;
  opacity: 0;
}
<h1 id='display-heading'>Welcome</h1>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda