【发布时间】:2012-12-16 11:51:46
【问题描述】:
我试图在鼠标悬停时缩放 SVG 路径,但因为我必须在将路径添加到纸上时对其进行转换,结果弄得一团糟。
请看: http://jsfiddle.net/chrisloughnane/Kc4q2/
使用此变换属性添加路径:
transform: 'S2.5,2.5,0,0'
在mouse in 上,我使用以下动画:
this.animate({transform: 's2.9,2.9,0,0'}, 200);
和mouse out 我恢复:
this.animate({transform: 's2.5,2.5,0,0' }, 400, "bounce");
在这里查看后,我发现有人提到了element.getBBox(),我尝试了这个,但我搞砸了。
var center = this.getBBox();
var adjustx = center.width / 2 ;//+ center.x;
var adjusty = center.height / 2 ;//+ center.y;
adjustx = (1 - 3)*adjustx;
adjusty = (1 - 3)*adjusty;
谁能指出我错过了什么?
或者推荐一个很好的工具来将 SVG 路径调整为新的默认值。我试过inkscape和http://svg-edit.googlecode.com/svn/branches/2.5.1/editor/svg-editor.html
tia
【问题讨论】: