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

166
Visualizações
Problem with Intersection Observer in Edge with absolutely positioned element

I have noticed that Intersection Observer does not work properly in Edge in a very narrow circumstance: when the observed element is absolutely positioned with its css property right set to 0. The same problem does not arise when I open the page in Chrome or Firefox.

Either it's an Edge bug or (more likely) I'm using Intersection Observer wrong. If the latter, please correct me!

Here's sample code to show the issue:

The Javascript

const options = {
  root: null,
  threshold: 1,
  rootMargin: "0px"
};

const observer = new IntersectionObserver(function(entries, observer) {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      entry.target.classList.add('is-on');
    } else {
      entry.target.classList.remove('is-on');
    }
  });
}, options);

items.forEach(item => {
  observer.observe(item);
})

The HTML

<div class="item1" data-set="items">Item 1</div>
<div class="item2" data-set="items">Item 2</div>

The CSS

.item1, 
.item2 {
  position: absolute;
  top: 1000px;
  padding: 1rem;
  background-color: yellow;
  transition: all 1s;
}

.item1 { left: 0; }

.item2 { right: 0; }

.item1.is-on,
.item2.is-on {background-color: red; }

The Issue

When the webpage with this code is opened in Chrome or Firefox, the boxes both transition from yellow to red, as expected. When it is opened in Edge, the left box (which uses left: 0) transitions to red but the right box (which uses right: 0) does not. I don't know why.

Oddly, if I use right: 1px (or something more than 0), the right box also transitions as expected.

about 4 years ago · Juan Pablo Isaza
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