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

132
Visualizações
Detect div visibility when browser position is out of the screen using Intersection Observer in Javascript

I need to detect visibility of a div which is on the viewport. I see that the Intersection Observer Api triggers on visibility change events when the browser is on the screen but doesn't trigger an event when the browser dragged out from screen and dragged in again. Is it possible to detect this kind of action using intersection observer or should I calculate myself using geometric approach?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It seems like in addition to the Intersection Observer API you could use the Page Visibility API which allows developers to react to changes in page visibility via the visibilitychange document event. New document.hidden and document.visibilityChange properties are also available. https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event

document.addEventListener("visibilitychange", function() {
  if (document.visibilityState === 'visible') {
    backgroundMusic.play();
  } else {
    backgroundMusic.pause();
  }
})

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