svg translate 操作
function dragElement(evt) { var target = evt.target; var id = target.id; var dx = evt.dx, dy = evt.dy; var scale = svgcanvas.scale(); var transformBaseVal = target.transform.baseVal; if(transformBaseVal.numberOfItems == 0){ var transformObject = svgRoot.createSVGTransform(); transformBaseVal.appendItem(transformObject); } var transformItem = transformBaseVal.getItem(0); var transformMatrix = transformItem.matrix; var ox = transformMatrix.e, oy = transformMatrix.f; var x = ox + dx / scale, y = oy + dy / scale; log("scale:" + scale + ",offset:" + dx / scale + "," + dy / scale); transformItem.setTranslate(x,y); } }