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

149
Visualizações
Popstate event is not firing on mobile after adding touch event listeners

I'm adding a new entry to my browser's history stack with pushState. Now popstate event should fire when pressing the back button, right? And at least on mobile, it requires some kind of user action before pressing the back button to fire (scroll or touch).

This is my current situation and it is working nicely on mobile if I click or scroll a bit before pressing the back button.

Now if I add touchstart, touchmove or touchend event listener then popstate event is firing only if I perform touch first and then press the back button. But it is not firing if I scroll only and do not perform touch.

Below are two snippets of code that explain the situation.

Alert is shown, only small scroll is required before pressing back button:

window.addEventListener('popstate', () => {
    alert('This is test');
});

Alert is not shown, requires click before pressing back button:

window.addEventListener('popstate', () => {
    alert('This is test');
});

document.addEventListener('touchmove', () => {
    // Empty eventListener here
});

Any ideas why it is not working with scroll-only after adding touch event listeners?

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