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

121
Vistas
Mobile devices touch event is not being triggered as many times as I clicked

I have developed a candy-crush like game using react and canvas, but it is not working as expected on mobile devices. I have these listeners:

if (isMobile) {
  canvas.addEventListener('touchstart', onMouseDown);
  canvas.addEventListener('touchend', onMouseUp);
} else {
  canvas.addEventListener('mousemove', onMouseMove);
  canvas.addEventListener('mousedown', onMouseDown);
  canvas.addEventListener('mouseup', onMouseUp);
  canvas.addEventListener('mouseout', onMouseOut);
}

and it works perfectly on desktop. But on mobile devices listener is not being triggered right away after I clicked second time. For example if I want to swap tiles I have to click on any tile and wait for like 1 second to click another one so swap function was triggered. If I click the second tile straight after I've clicked the first one: listener will not be triggered. And it works the same way even with simple console.log function. If I've clicked N times, I will see far less logs in the console.

Here is my FPS control function:

const updateFps = (dt) => {
  if (fpstime > 10) {
    fps = Math.round(framecount / fpstime);

    fpstime = 0;
    framecount = 0;
  }

  fpstime += dt;
  framecount += 1;
};

and here is my animation function:

const main = (tframe) => {
  requestAnimationFrame(main);

  update(tframe);
  render();
};

Is there any way to improve usability on mobile devices? Can it somehow be connected with rerenders of fps limitations?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So, I found out that somehow only on ios devices DOM and scripts are being blocked after first touch has triggered the listener. So after few hours of suffering a casual e.preventDefault() did the job. So simply use it in your listener :)

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