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

121
Visualizações
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 Respostas
Responde à pergunta

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