出于特定原因,我必须进行组翻译(SVG)。我不知道为什么我不能正确完成它,因为翻译完成后,在另一个单击组上,它将重置翻译到开始位置,并使我的傻瓜在SVG画布上跑来跑去。 我写的准系统例如在链接:http://www.atarado.com/en/stripboard-layout-software/group-translation-problem.svg,这里是代码:SVG组翻译问题
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script><![CDATA[
function startMove(evt){
x1=evt.clientX;
y1=evt.clientY;
group=evt.target.parentNode;
group.setAttribute("onmousemove","moveIt(evt)");
}
function moveIt(evt){
dx=evt.clientX-x1;
dy=evt.clientY-y1;
group.setAttributeNS(null,"transform","translate("+ dx + ", " + dy +")");
}
function drop(){
group.setAttributeNS(null, "onmousemove",null);
}
]]></script>
<rect x="0" y="0" width="100%" height="100%" fill="dodgerblue"/>
<g id="BC" transform="translate(0, 0)" onmousedown="startMove(evt)" onmouseup="drop()"><circle id="C" cx="60" cy="60" r="22" fill="lightgrey" stroke="black" stroke-width="8"/><circle id="B" cx="120" cy="60" r="22" fill="orange" stroke="black" stroke-width="8" /></g>
</svg>
任何人都愿意帮助是值得欢迎的。
你可能会对这个例子感兴趣:http://phrogz.net/SVG/drag_under_transformation.xhtml – Phrogz
谢谢你的例子,它很有教育意义。 – Alex