jQuery:Touchmove在iOS上没有按预期工作

时间:2013-04-29 18:09:32

标签: javascript jquery ios touch

该应用程序可在桌面上运行,但不适用于移动设备。当您单击DONE时,应用程序将打开一个新窗口并显示图形的输出,但在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/

任何帮助都将不胜感激。

谢谢!

0 个答案:

没有答案