javascript - Handling touch-based events -
i have touch events:
if( 'ontouchstart' in document.body) { usevkeys = true; canvas.addeventlistener("touchstart",function(e) {evt.call(this,e);},false); canvas.addeventlistener("touchend",function(e) {evt.call(this,e);},false); canvas.addeventlistener("touchmove",function(e) {evt.call(this,e);},false); } else { canvas.addeventlistener("mousemove",function(e) {evt.call(this,e);},false); canvas.addeventlistener("click",function(e) {evt.call(this,e);},false); }
this works fine on laptop, , on phone. however, have wonder, how react in environment has both touchscreen , normal mouse? mouse trigger touch events, phone triggers mousemove
events?
what can make sure works?
a touchstart
triggers click
event touchend
has fired (-> if hasn't been canceled). should remove else clause , should fine!
microsoft went different way touch events in ie10 harmonize pointer-devices pointer , gesture events can check if has been fired mouse, pen or finger - or perhaps kinect-style device in future.
Comments
Post a Comment