2

I have a canvas in javascript which has one eventListener "touchstart" attached to it. But, when I build this canvas onto a cordova mobile app, each click lags for 300ms or until the user releases their finger, which ever comes first.

Is there a solution to this? I've tried using fastclick.js, but with no luck. If you do know how to use fastclick, I would greatly appreciate step by step instructions on how to include it. Anything helps, I've been trying to research this everywhere with no result. Thanks so much in advance!

// HTML
<script type='application/javascript' src='fastclick-master/lib/fastclick.js'></script>

//JS
var canvas = document.getElementById("canvas");
canvas.addEventListener("touchstart", getPosition, false);
FastClick.attach(canvas);
function getPosition(event) {
    pointerX = event.touches[0].clientX - canvas.offsetLeft;
    pointerY = event.touches[0].clientY - canvas.offsetTop;
}
Assafi Cohen-Arazi
  • 837
  • 10
  • 30

0 Answers0