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

119
Vistas
Bugged CSS animation in Firefox using Intersection Observer

I'm using Intersection Observer to add a class to specific elements as they enter the viewport. The class triggers a CSS animation.

Specifically, I'm adding .swipe to any .highlight elements that enter the viewport.

In Firefox only, the animation runs on time but gets cut about 20% short.

<div class="description">
<p><span class="highlight">Travel companion app</span> that displays nearby restaurants, hotels...</p>
</div>

const observer = new IntersectionObserver(entries => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      entry.target.classList.add('swipe')
    }
  })
});

document.querySelectorAll('.highlight').forEach((i) => {
  if (i) {
    observer.observe(i);
  }
});
.highlight {
  color: black;
  background-color: white;
  padding-left: 5px;
  padding-right: 5px;
}

.swipe {
  position: relative;
  width: fit-content;
}

.swipe::after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 100%;
  width: 0%;
  height: 100%;
  background-color: black;
  animation: swipe 1.5s ease-out 1s forwards;
}

.swipe--delay::after {
  background-color: black;
  animation-delay: 1.5s;
}

.swipe h1 {
  color: black;
  opacity: 0;
  animation: fade 0.01s ease-out 1.75s forwards;
}

.swipe h2,
.swipe h3 {
  color: black;
  opacity: 0;
  animation: fade 0.01s ease-out 2.25s forwards;
}

@keyframes swipe {
  0% {
    right: 100%;
    left: 0;
    width: 0%;
  }
  50% {
    right: 0;
    left: 0;
    width: 100%;
  }
  100% {
    right: 0;
    left: 100%;
    width: 0%;
  }
}

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

0

The .description div had a text-align: justify property. Firefox seems to calculate the width of justified inline elements differently than other browsers. There may be another way to fix this, but for now I'm happy removing the text-align: justify property altogether.

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