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

147
Visualizações
Add an addEventListner on a class remove

I made some fandeIn and fadeOut codes to an exercise. I'm trying to remove the setTimeout() on the fadeIn(). Like using an addEventListner maybe, but there is no transition on .displayNone.

On the MDN I just found transitions interacting with EventListner.

function fadeOut(disable) {
    disable.classList.remove('visible');
    disable.classList.add('hidden');
    disable.addEventListener('transitionend', () => disable.classList.add('displayNone'));
};

function fadein(enable, timer) {
    if (!timer) timer = 350;
    enable.classList.remove('displayNone');
    setTimeout(function () {
        enable.classList.remove('hidden');
        enable.classList.add('visible');
    }, timer);
};
.displayNone {
    display: none;
}

.visible {
    visibility: visible;
    opacity: 1;
    transition: opacity 1.5s linear;
}

.hidden {
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 350ms, opacity 350ms, display 350ms linear;
}

P.S.: This works good, I'm just trying another way to make it works too.

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

0

The setTimeout method returns a timeout descriptor/id (actually just an integer). You may use it to remove the timeout later:

// setting timeout
var timeout = window.setTimeout(function(){}, 5000);
window.clearTimeout( timeout )
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