aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/event.js b/src/event.js
index a9b1cfc..8e485b6 100644
--- a/src/event.js
+++ b/src/event.js
@@ -26,4 +26,37 @@
return this;
};
+
});
+
+// Add event binder in the SVG namespace
+SVG.on = function(node, event, listener) {
+ if (node.addEventListener)
+ node.addEventListener(event, listener, false);
+ else
+ node.attachEvent('on' + event, listener);
+};
+
+// Add event unbinder in the SVG namespace
+SVG.off = function(node, event, listener) {
+ if (node.removeEventListener)
+ node.removeEventListener(event, listener, false);
+ else
+ node.detachEvent('on' + event, listener);
+};
+
+//
+SVG.extend(SVG.Element, {
+ // Bind given event to listener
+ on: function(event, listener) {
+ SVG.on(this.node, event, listener);
+
+ return this;
+ },
+ // Unbind event from listener
+ off: function(event, listener) {
+ SVG.off(this.node, event, listener);
+
+ return this;
+ }
+}); \ No newline at end of file