From 30f7761e667607a696f91711f5c060002eb9edea Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Wed, 18 Nov 2015 14:38:33 +0100 Subject: added `gbox()` to group to get bbox with translation included (fixes #405) --- src/group.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/group.js b/src/group.js index 1b61371..df5c001 100644 --- a/src/group.js +++ b/src/group.js @@ -4,7 +4,7 @@ SVG.G = SVG.invent({ // Inherit from , inherit: SVG.Container - + // Add class methods , extend: { // Move over x-axis @@ -23,8 +23,23 @@ SVG.G = SVG.invent({ , cy: function(y) { return y == null ? this.tbox().cy : this.y(y - this.tbox().height / 2) } + , gbox: function() { + + var bbox = this.bbox() + , trans = this.transform() + + bbox.x += trans.x + bbox.x2 += trans.x + bbox.cx += trans.x + + bbox.y += trans.y + bbox.y2 += trans.y + bbox.cy += trans.y + + return bbox + } } - + // Add parent method , construct: { // Create a group element -- cgit v1.2.3