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

156
Visualizações
Another JavaScript Bug: adding transition to element causes extra 0s

Using this lines I tried to add transitions to the element:

transition.style.transform = 'translateY(0)';
            transition.style['-webkit-transition'] = 'opacity 0.9s ease-in-out';

            setTimeout(() => {
                type == 'showContainer' ? transition.style.opacity = 1 :
                                          transition.style.opacity = 0;
            }, 100);

But it sets the transition like this:

element.style {
    transform: translateY(0px);
    transition: opacity 0.9s ease-in-out 0s;
    opacity: 1;
}

The extra 0s is included and ruins the transition!!! How can I fix this?

I just want to add a simple opacity transition ;(

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

0

Couple of things:

To set the style property with it's css name, use style.setProperty(property, value). To set it directly with javascript, the properties have different names, such as backgroundColor as opposed to background-color.

Why do you use a timeout? You can directly set the opacity and the transition. There will be no timing issues.

Use transition instead of -webkit-transition. It is compatible with every browser. And can be directly set on style property.

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