对不起我的英语,我来自阿根廷。我正在用 Eclipse 开发一个 HTML5 应用程序。当程序在 IMG 元素上加载图像时,会正确检测到事件touchstart、touchmove和touchend 。但是当我需要旋转图像时,我使用了 CANVAS 和toDataUrl()方法,然后似乎没有检测到触摸事件。我使用的源代码是这样的(考虑所有对象、变量和函数声明良好):
var context = canvas.getContext("2d");
function loadImage(strFile, intDeg) {
if (intDeg == 90) image.onload = function() { rotateImage(); };
imagePhoto.src = strFile;
}
function rotateImage() {
image.onload = function() { moveImage(); };
canvas.width = image.height;
canvas.height = image.width;
context.translate(canvas.width, 0);
context.rotate(90 * Math.PI / 180);
context.drawImage(image, 0, 0, canvas.width, canvas.height);
context.restore();
image.src = canvas.toDataURL("image/png");
}
image.addEventListener("touchstart", downEvent, true, true);
image.addEventListener("touchmove", moveEvent, true, true);
image.addEventListener("touchend", upEvent, true, true);
谢谢!