diff options
Diffstat (limited to 'src/bbox.js')
-rwxr-xr-x | src/bbox.js | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/bbox.js b/src/bbox.js index c68bec5..1632a02 100755 --- a/src/bbox.js +++ b/src/bbox.js @@ -2,19 +2,19 @@ SVG.BBox = function(element) { var box - /* initialize zero box */ + // Initialize zero box this.x = 0 this.y = 0 this.width = 0 this.height = 0 - /* get values if element is given */ + // Get values if element is given if (element) { try { - /* actual, native bounding box */ + // Actual, native bounding box box = element.node.getBBox() } catch(e) { - /* fallback for some browsers */ + // Fallback for some browsers box = { x: element.node.clientLeft , y: element.node.clientTop @@ -23,16 +23,16 @@ SVG.BBox = function(element) { } } - /* include translations on x an y */ + // Include translations on x an y this.x = box.x + element.trans.x this.y = box.y + element.trans.y - /* plain width and height */ + // Plain width and height this.width = box.width * element.trans.scaleX this.height = box.height * element.trans.scaleY } - /* add center, right and bottom */ + // Add center, right and bottom boxProperties(this) } @@ -41,18 +41,15 @@ SVG.BBox = function(element) { SVG.extend(SVG.BBox, { // merge bounding box with another, return a new instance merge: function(box) { - var b = new SVG.BBox() + var b = new SVG.BBox - /* merge box */ + // Merge box b.x = Math.min(this.x, box.x) b.y = Math.min(this.y, box.y) b.width = Math.max(this.x + this.width, box.x + box.width) - b.x b.height = Math.max(this.y + this.height, box.y + box.height) - b.y - /* add center, right and bottom */ - boxProperties(b) - - return b + return boxProperties(b) } })
\ No newline at end of file |