我已经在HTML页面中创建了SVG图像,现在我想移动有关使用JavaScript按钮的SVG形状。我的应用程序的JSFiddle在这里:http : //jsfiddle.net/johndavies91/xwMYY/
按钮已显示,但单击按钮后未显示其功能。
功能代码如下:
function rotatex() {
document.getElementById("inner-arrow").setRotate(45,NativeCenterX,NativeCenterY)
}
function rotatey() {
document.getElementById("middle-arrow").setRotate(45,NativeCenterX,NativeCenterY)
}
function rotatez() {
document.getElementById("outer-arrow").setRotate(45,NativeCenterX,NativeCenterY)
}
及其相应的按钮;
<input id="button1" type="button" value="Rotate Inner Short Arrows 45*"
onclick="rotatex()"/>
<input id="button1" type="button" value="Rotate Middle Short Arrows 45*"
onclick="rotatey()"/>
<input id="button1" type="button" value="Rotate Outer Short Arrows 45*"
onclick="rotatez()"/>
我正在尝试围绕形状的原点旋转它们。有人可以向我解释为什么此代码无法正常工作。谢谢
在这里查看更新的小提琴:http : //jsfiddle.net/2da4B/
这.setAttribute("transform", "rotate(45)")
代替了setRotate
:
function rotatex() {
var innerArrow = document.getElementById("inner-arrow");
innerArrow.setAttribute("transform", "rotate(45)");
}
它绕0,0
原点旋转45度-从您的问题中尚不清楚这是否是您要的内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句