Fixed issue 339...for Firefox
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@975 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
da09855230
commit
da6fb0a3cc
|
@ -5469,34 +5469,47 @@ function BatchCommand(text) {
|
||||||
var bb = elem.getBBox();
|
var bb = elem.getBBox();
|
||||||
var angle = canvas.getRotationAngle(elem) * Math.PI / 180.0;
|
var angle = canvas.getRotationAngle(elem) * Math.PI / 180.0;
|
||||||
if (angle) {
|
if (angle) {
|
||||||
var rminx = Number.MAX_VALUE, rminy = Number.MAX_VALUE,
|
// Accurate way to get BBox of rotated element in Firefox:
|
||||||
rmaxx = Number.MIN_VALUE, rmaxy = Number.MIN_VALUE;
|
// Put element in group and get its BBox
|
||||||
var cx = round(bb.x + bb.width/2),
|
var g = document.createElementNS(svgns, "g");
|
||||||
cy = round(bb.y + bb.height/2);
|
var parent = elem.parentNode;
|
||||||
var pts = [ [bb.x - cx, bb.y - cy],
|
parent.replaceChild(g, elem);
|
||||||
[bb.x + bb.width - cx, bb.y - cy],
|
g.appendChild(elem);
|
||||||
[bb.x + bb.width - cx, bb.y + bb.height - cy],
|
bb = g.getBBox();
|
||||||
[bb.x - cx, bb.y + bb.height - cy] ];
|
parent.insertBefore(elem,g);
|
||||||
var j = 4;
|
parent.removeChild(g);
|
||||||
while (j--) {
|
|
||||||
var x = pts[j][0],
|
|
||||||
y = pts[j][1],
|
|
||||||
r = Math.sqrt( x*x + y*y );
|
|
||||||
var theta = Math.atan2(y,x) + angle;
|
|
||||||
x = round(r * Math.cos(theta) + cx);
|
|
||||||
y = round(r * Math.sin(theta) + cy);
|
|
||||||
|
|
||||||
// now set the bbox for the shape after it's been rotated
|
// Old method: Works by giving the rotated BBox,
|
||||||
if (x < rminx) rminx = x;
|
// this is (unfortunately) what Opera and Safari do
|
||||||
if (y < rminy) rminy = y;
|
// natively when getting the BBox of the parent group
|
||||||
if (x > rmaxx) rmaxx = x;
|
// var rminx = Number.MAX_VALUE, rminy = Number.MAX_VALUE,
|
||||||
if (y > rmaxy) rmaxy = y;
|
// rmaxx = Number.MIN_VALUE, rmaxy = Number.MIN_VALUE;
|
||||||
}
|
// var cx = round(bb.x + bb.width/2),
|
||||||
|
// cy = round(bb.y + bb.height/2);
|
||||||
bb.x = rminx;
|
// var pts = [ [bb.x - cx, bb.y - cy],
|
||||||
bb.y = rminy;
|
// [bb.x + bb.width - cx, bb.y - cy],
|
||||||
bb.width = rmaxx - rminx;
|
// [bb.x + bb.width - cx, bb.y + bb.height - cy],
|
||||||
bb.height = rmaxy - rminy;
|
// [bb.x - cx, bb.y + bb.height - cy] ];
|
||||||
|
// var j = 4;
|
||||||
|
// while (j--) {
|
||||||
|
// var x = pts[j][0],
|
||||||
|
// y = pts[j][1],
|
||||||
|
// r = Math.sqrt( x*x + y*y );
|
||||||
|
// var theta = Math.atan2(y,x) + angle;
|
||||||
|
// x = round(r * Math.cos(theta) + cx);
|
||||||
|
// y = round(r * Math.sin(theta) + cy);
|
||||||
|
//
|
||||||
|
// // now set the bbox for the shape after it's been rotated
|
||||||
|
// if (x < rminx) rminx = x;
|
||||||
|
// if (y < rminy) rminy = y;
|
||||||
|
// if (x > rmaxx) rmaxx = x;
|
||||||
|
// if (y > rmaxy) rmaxy = y;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// bb.x = rminx;
|
||||||
|
// bb.y = rminy;
|
||||||
|
// bb.width = rmaxx - rminx;
|
||||||
|
// bb.height = rmaxy - rminy;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
|
|
Loading…
Reference in New Issue