javascript - trying work with touch events -


i using mouse events draw free line (using raphael) working fine mouse events not working touch events. should need replace event.pagex event.screenx or event.clientx if touch event?

var board = $("#board"); board.bind("mousedown", _mousedownhandler);         board.bind("touchstart", _mousedownhandler); function _drawfreelinebegin(x, y) {         board.lineel.path = _drawoptions.paper.path("m"                 + (x - _drawoptions.offset.left) + ","                 + (y - _drawoptions.offset.top));         _setnewelementproperties(board.lineel.path,                 configuration.getproperties("freeline"));             board.bind("mousemove.mmu", _mousemovehandler);         board.one("mouseup.mmu", _mouseuphandler);         board.bind("touchmove.mmu", _mousemovehandler);         board.one("touchend.mmu", _mouseuphandler);     } function _mousedownhandler(event) { if(event.type == "touchstart"){             event = event.touches[0];         } _drawfreelinebegin(event.pagex, event.pagey); return false; }      function _mousemovehandler(event) {     if(event.type == "touchmove"){             event = event.touches[0];         }     board.lineel.path                         .attr(                                 "path",                                 board.lineel.path.attr("path")                                         + "l"                                         + (event.pagex - )                                         + ","                                         + (event.pagey ));                 return true;  }  function _mouseuphandler(event) { board.unbind(".mmu");  board.lineel.path = null;     event.stoppropagation();     event.preventdefault(); } 

figured out issue, need replace event.touches[0]; event.originalevent.touches[0];


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -