Reputation: 317
Using the phpacademy painting app tutorial, I attempted to add touchscreen support.I have the same code for mouse and touch, however touchup and down are not triggered.
canvas.addEventListener('mousedown', engage);
canvas.addEventListener('mousemove', putPoint);
canvas.addEventListener('touchstart', engage);
canvas.addEventListener('touchmove', putPoint);
canvas.addEventListener('mouseup', disengage);
canvas.addEventListener('mouseout', disengage);
canvas.addEventListener('touchend', disengage);
Upvotes: 1
Views: 3128
Reputation: 668
The canvas element doesn't receive the touchstart events (lame I know). In order to get it to work you'll have to hack something up like absolute position a div over the canvas and use the div to catch the touchstart event.
Upvotes: 2