我正在使用webview显示svg文件,并使用javascript绘制一些工具。对于移动工具,我使用下面的代码调用startmove函数,如下所示:
shape.setAttributeNS(null, "ontouchstart", "startMove(evt,this)");
shape.setAttributeNS(null, "ontouchend", "drop(evt,this)");
功能如下:
function startMove(evt,ele){
console.log("----marker start moving----");
if(isDrawing == '1')
{
return false;
}
document.getElementById("ssvg").style.cursor = 'move';
drawObject='';
drawLine=0;
drawCircle=0;
C=evt.target;
handleCircleClick(ele);
document.documentElement.setAttribute("onmousemove","moveIt(evt)");
document.documentElement.setAttribute("ontouchmove","moveIt(evt)");
}
function moveIt(evt){
console.log("----marker moving----");
}
它在Android 5.0及以上版本上运行良好。但不适用于Android 4.4及以下的默认浏览器。