【发布时间】:2015-10-28 14:16:35
【问题描述】:
我正在尝试在 onmouseover 时缩放 svg 部分并在 onmouseout 上重新缩放到以前的大小
无法读取 null 的属性“getBBox”
D=document;
var lib = 'http://www.w3.org/2000/svg';
D.
function magnify(scale,x){ x.setAttribute("transform","matrix(1.5 0 0 1 0 0)");
}
function minimize(x){ x.setAttribute("transform","matrix(1 0 0 1 0 0)");
}
function getCenter(selection)
{ bbox=D.getElementById("#"+selection).getBBox();
return[bbox.x + bbox.width/2,bbox.y + bbox.height/2];
}
function reCoor(scale, x)
{
var coor = getCenter(x);
var newX=x[0].width*(1-scale);
var newY=x[1].height*(1-scale);
var output = "matrix(" + scale + " 0 0 " + scale + " " + newX + " " + newY +")";
return[output];
}
【问题讨论】:
-
在
document.getElementById(element)中,元素在javascript中不需要#。 -
所以这很有帮助
-
你在讽刺吗?
-
我问一个问题,你投票给我减去你是吗?在某些平台(firefox,ie)中可能会使用“#”。
-
我没有投票。不消极也不积极。不要做假设。
标签: javascript html css svg