aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Walch <rwalch@hugeinc.com>2013-04-10 18:47:59 -0400
committerRob Walch <rwalch@gmail.com>2013-04-10 21:42:59 -0400
commitce1eb91fac1edc923b317caa83a3a4ab10e7c020 (patch)
treea43ab5f0a0856e5640e8963d462d2a30105f6377
parent582bd10836341ebfa752e7da92c6871fbc1f04fe (diff)
downloadsvg.js-ce1eb91fac1edc923b317caa83a3a4ab10e7c020.tar.gz
svg.js-ce1eb91fac1edc923b317caa83a3a4ab10e7c020.zip
node.getBBox() fallback. Fixes #21
-rw-r--r--src/bbox.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bbox.js b/src/bbox.js
index f58e77b..ee101b2 100644
--- a/src/bbox.js
+++ b/src/bbox.js
@@ -1,7 +1,17 @@
SVG.BBox = function(element) {
/* actual, native bounding box */
- var box = element.node.getBBox()
+ var box
+ try {
+ box = element.node.getBBox()
+ } catch(err) {
+ box = {
+ x: element.node.clientLeft,
+ y: element.node.clientTop,
+ width: element.node.clientWidth,
+ height: element.node.clientHeight
+ }
+ }
/* include translations on x an y */
this.x = box.x + element.trans.x