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

79
Visualizações
observer javascript proplem

i want to add an observer so it can add a class when viewed and remove it when it get out of view what is wrong? the proplem is : The code adds the class but doesnt remove The class when the section gets out of viewed

const options = {
    threshold: 0.75,
}
const observer = new IntersectionObserver(function (enteries ,observer) {
    enteries.forEach(entry => {
        if (entry.isIntersecting > 0) {
            entry.target.classList.add("StyleSection");
            console.log(entry.target);
           
        }
        else if (entry.isIntersecting === 0){
            sections.classList.remove("StyleSection");
            console.log(entry.target);
            observer.unobserve(section);
        }
        
    });
}, options);`enter code here`
sections.forEach(section => {
    observer.observe(section);
});
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