The getBBox() function of Snap is really awesome as it does what the browsers should have done when they implemented getBoundingClientRect(), but it's behaving extrangely when it comes to do it's work with groups. That is:
<ellipse id="elli" cx="200" cy="200" rx="100" ry="50" stroke="black" fill="none" transform="rotate(30, 200, 200)"></ellipse>
I use getBBox() on it and everything is allright:
var elli = paper.select('#elli');
var box = elli.getBBox();
d.rect(box.x, box.y, box.width, box.height).attr({stroke: 'red', fill: 'none'});
after this code the red box appears completly stick to the rotated ellipse, but if I change the markup to this:
<g id="elli" transform="rotate(30, 200, 200)">
<ellipse cx="200" cy="200" rx="100" ry="50" stroke="black" fill="none"></ellipse>
</g>
then the red box behaves as it was surrounding the BoundingClientRect, that is bigger than the ellipse, so the red box sides are separated from the ellipse.
Is this a bug or is it the intended behaviour?
I need to get the boundings of a set of figures inside a group and I can't manage to do now.
Maybe I haven't described the issue correctly or we are not understanding each other.
I've prepared a CodePen to clarify the issue. Please, see it here:
The correct behaviour SHOULD be that the two red boxes were equal, like in case 1. Isn't it?