Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!