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

155
Vistas
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 Respuestas
Responde la pregunta

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 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