summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-09-03 12:15:16 +0200
committerwout <wout@impinc.co.uk>2014-09-03 12:15:16 +0200
commit69da2d385450daa158d75ebe59449cc044ec8022 (patch)
tree94d13794806978d4a8ca4d50ac0323b7d93475b7 /src
parent826649995f1aae806fb9bf8464a4259c4290c4fb (diff)
downloadsvg.js-69da2d385450daa158d75ebe59449cc044ec8022.tar.gz
svg.js-69da2d385450daa158d75ebe59449cc044ec8022.zip
Firefox fixes and event specs
Diffstat (limited to 'src')
-rwxr-xr-xsrc/boxes.js10
-rwxr-xr-xsrc/event.js17
-rw-r--r--src/matrix.js2
3 files changed, 21 insertions, 8 deletions
diff --git a/src/boxes.js b/src/boxes.js
index 2c5cd8b..0b90f60 100755
--- a/src/boxes.js
+++ b/src/boxes.js
@@ -5,17 +5,19 @@ SVG.BBox = SVG.invent({
if (element) {
var box
- // find native bbox
- if (element.node.getBBox)
+ // yes this is ugly, but Firefox can be a bitch when it comes to elements that are not yet rendered
+ try {
+ // find native bbox
box = element.node.getBBox()
- // mimic bbox
- else
+ } catch(e) {
+ // mimic bbox
box = {
x: element.node.clientLeft
, y: element.node.clientTop
, width: element.node.clientWidth
, height: element.node.clientHeight
}
+ }
// plain x and y
this.x = box.x
diff --git a/src/event.js b/src/event.js
index 6108155..3f7e656 100755
--- a/src/event.js
+++ b/src/event.js
@@ -39,15 +39,26 @@ SVG.registerEvent = function(event) {
// Add event binder in the SVG namespace
SVG.on = function(node, event, listener) {
+ // create listener
var l = listener.bind(node.instance || node)
- SVG.listeners[listener] = l
+
+ // ensure node reference
+ SVG.listeners[node] = SVG.listeners[node] || {}
+
+ // reference listener
+ SVG.listeners[node][listener] = l
+
+ // add listener
node.addEventListener(event, l, false)
}
// Add event unbinder in the SVG namespace
SVG.off = function(node, event, listener) {
- node.removeEventListener(event, SVG.listeners[listener], false)
- delete SVG.listeners[listener]
+ // remove listener
+ node.removeEventListener(event, SVG.listeners[node][listener], false)
+
+ // remove listener reference
+ delete SVG.listeners[node][listener]
}
//
diff --git a/src/matrix.js b/src/matrix.js
index d1757f3..cbd053f 100644
--- a/src/matrix.js
+++ b/src/matrix.js
@@ -15,7 +15,7 @@ SVG.Matrix = SVG.invent({
// merge source
for (i = abcdef.length - 1; i >= 0; i--)
- this[abcdef[i]] = typeof source[abcdef[i]] === 'number' ?
+ this[abcdef[i]] = source && typeof source[abcdef[i]] === 'number' ?
source[abcdef[i]] : base[abcdef[i]]
}