Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
Is the `click` event guaranteed to fire right after `touchend`, before `touchend`'s event handler can run?

There's a Chrome bug where click doesn't fire after a touchend: https://bugs.chromium.org/p/chromium/issues/detail?id=1141207#c10

I want to simulate a click using dispatchEvent:

let timer: number | null = null;
window.addEventListener('touchend', event => {
  if (timer) {
    clearTimeout(timer);
  }
  timer = window.setTimeout(() => {
    event.target?.dispatchEvent(new Event('click', {
      bubbles: true,
      cancelable: true,
    }));
  }, 0);
});

window.addEventListener('click', () => {
  if (timer) {
    clearTimeout(timer);
  }
});

I'm assuming it'll be impossible for the timeout callback to run before the click handler runs (if the click event occurs). With this assumption, I can make the timeout delay 0. If this assumption is false, then I'd need a longer delay, maybe 1-2 frames. Is click guaranteed to fire right after touchend, before touchend's event handler runs?

Are there

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda