该应用程序在台式机上运行良好,但在移动设备上却不行。当您单击完成时,应用程序将打开一个新窗口并向您显示绘图的输出,但在 iOS 上,所有坐标都是 0,0...所以看起来这些点根本没有保存在移动设备中。
问题很可能出现在 JS 的第 109 到 111 行或第 171 到 184 行,我将其包括在下面:
处理触摸事件的部分:
$(trackingLayer).on('mousedown touchstart', function(e) {
e.originalEvent.preventDefault();
isTracking = true;
curMouseX = curMouseY = -1;
if (curTool === "draw") {
var o = {};
o.painLevel = curPainLevel;
o.path = [];
DrawPoints.push(o);
}
}).on('mousemove touchmove', function(e) {
e.originalEvent.preventDefault();
trackMoveMouse($(this), e);
}).on('mouseup mouseleave touchend', function(e) {
e.originalEvent.preventDefault();
isTracking = false;
});
以及记录点的区域:
var canvasOffset = ID.offset(); //or $(this).offset(); if you really just want the current element's offset
curMouseX = e.pageX - canvasOffset.left;
curMouseY = e.pageY - canvasOffset.top;
if (curMouseX !== -1 && prevMouseX !== -1) {
var o = {};
o.x = curMouseX / curZoom;
o.y = curMouseY / curZoom;
DrawPoints[DrawPoints.length - 1].path.push(o);
//log("Shapes Recorded: " + DrawPoints.length);
drawImage();
}
我为此设置了一个 jsfiddle:http: //jsfiddle.net/nbernhard/dSED8/
任何帮助,将不胜感激。
谢谢!