summaryrefslogtreecommitdiffstats
path: root/src/set.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-01-30 19:44:40 +0100
committerwout <wout@impinc.co.uk>2014-01-30 19:44:40 +0100
commitbd7e10cb46e0cb113983c69f4f48c7a42a776809 (patch)
tree37ad5746b3e66879a33b6fe85c5e5718ec58a18b /src/set.js
parentf6fc66659d0fc391442f58e8c82f965b38995725 (diff)
downloadsvg.js-bd7e10cb46e0cb113983c69f4f48c7a42a776809.tar.gz
svg.js-bd7e10cb46e0cb113983c69f4f48c7a42a776809.zip
Added `relative()`method for relative translations
Diffstat (limited to 'src/set.js')
-rwxr-xr-xsrc/set.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/set.js b/src/set.js
index 1fba388..3808a91 100755
--- a/src/set.js
+++ b/src/set.js
@@ -56,6 +56,28 @@ SVG.extend(SVG.Set, {
, valueOf: function() {
return this.members
}
+ // Get the bounding box of all members included or empty box if set has no items
+, bbox: function(){
+ var box = new SVG.BBox()
+
+ /* return an empty box of there are no members */
+ if (this.members.length == 0)
+ return box
+
+ /* get the first rbox and update the target bbox */
+ var rbox = this.members[0].rbox()
+ box.x = rbox.x
+ box.y = rbox.y
+ box.width = rbox.width
+ box.height = rbox.height
+
+ this.each(function() {
+ /* user rbox for correct position and visual representation */
+ box = box.merge(this.rbox())
+ })
+
+ return box
+ }
})