aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/event.js b/src/event.js
index 115e175..60f7a69 100644
--- a/src/event.js
+++ b/src/event.js
@@ -16,15 +16,10 @@
// add event to SVG.Element
SVG.Element.prototype[event] = function(f) {
- var self = this
-
// bind event to element rather than element node
- this.node['on' + event] = typeof f == 'function' ?
- function() { return f.apply(self, arguments) } : null
-
+ SVG.on(this.node, event, f)
return this
}
-
})
// Initialize listeners stack
@@ -33,7 +28,7 @@ SVG.handlerMap = []
SVG.listenerId = 0
// Add event binder in the SVG namespace
-SVG.on = function(node, event, listener, binding) {
+SVG.on = function(node, event, listener, binding, options) {
// create listener, get object-index
var l = listener.bind(binding || node.instance || node)
, index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1
@@ -53,7 +48,7 @@ SVG.on = function(node, event, listener, binding) {
SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l
// add listener
- node.addEventListener(ev, l, false)
+ node.addEventListener(ev, l, options || false)
}
// Add event unbinder in the SVG namespace
@@ -61,6 +56,7 @@ SVG.off = function(node, event, listener) {
var index = SVG.handlerMap.indexOf(node)
, ev = event && event.split('.')[0]
, ns = event && event.split('.')[1]
+ , namespace = ''
if(index == -1) return
@@ -118,8 +114,8 @@ SVG.off = function(node, event, listener) {
//
SVG.extend(SVG.Element, {
// Bind given event to listener
- on: function(event, listener, binding) {
- SVG.on(this.node, event, listener, binding)
+ on: function(event, listener, binding, options) {
+ SVG.on(this.node, event, listener, binding, options)
return this
}
@@ -145,4 +141,4 @@ SVG.extend(SVG.Element, {
, event: function() {
return this._event
}
-}) \ No newline at end of file
+})