aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-09-22 20:51:46 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-09-22 20:51:46 +0200
commitdd190c872b05e3d0d502235cbea089a7766e4177 (patch)
tree0c52c86e3ebb0fc564064dec6d2e963922c833dd /src/event.js
parent9fce07dc8c2e4772051c6944849d32420496a261 (diff)
downloadsvg.js-dd190c872b05e3d0d502235cbea089a7766e4177.tar.gz
svg.js-dd190c872b05e3d0d502235cbea089a7766e4177.zip
Added custom context binding for event callbacks
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/event.js b/src/event.js
index 451b904..ef8630d 100644
--- a/src/event.js
+++ b/src/event.js
@@ -32,9 +32,9 @@ SVG.listeners = []
SVG.handlerMap = []
// Add event binder in the SVG namespace
-SVG.on = function(node, event, listener) {
+SVG.on = function(node, event, listener, binding) {
// create listener, get object-index
- var l = listener.bind(node.instance || node)
+ var l = listener.bind(binding || node.instance || node)
, index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1
, ev = event.split('.')[0]
, ns = event.split('.')[1] || '*'
@@ -110,8 +110,8 @@ SVG.off = function(node, event, listener) {
//
SVG.extend(SVG.Element, {
// Bind given event to listener
- on: function(event, listener) {
- SVG.on(this.node, event, listener)
+ on: function(event, listener, binding) {
+ SVG.on(this.node, event, listener, binding)
return this
}