Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
Javascript: addEventListener for transitionend does not execute function

I have the following code which is supposed to make a banner fade into view, which it does. However, there are additional effects I want to trigger once the transition has completed, but I cannot get the transitionend event to trigger a call to a function.

  modalBanner.classList.remove("fade-in", "fade-out");
  modalBanner.classList.add("hidden");
  modalBanner.innerHTML = bannerText;
  if (bannerText != "") {
    console.log("adding transition");
    modalBanner.classList.add("fade-in");
    var qs = document.querySelector('.fade-in');
    console.log(qs);
    qs.addEventListener("transitionend", () => { console.log('Transition ended'); });   
    modalBanner.classList.remove("hidden");
    console.log("transition added");
  } 

I am executing this in Chrome v93, which this site says supports transitionend. My console log shows:

adding transition                          ​GameTracker.html:288
 <div class=​"modalBanner fade-in">​…​</div>  ​GameTracker.html:291
transition added                           GameTracker.html:294
>

As you can see, the fade-in class does get added, and the fade-in does work. But I never get the Transition ended message. Any ideas as to where I am going wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Good Greif! I found the problem. I was posting a comment to include my css for the fade-in effect and noticed that the css is using animation, not transition. I forgot that I had changed the css a while back.

I switched the javascript to use addEventListener("animationend"... and it worked.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda