aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-22 20:31:58 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-22 20:31:58 +0200
commit408940add58e81e7879098682e94504a8cf3a734 (patch)
treeb7d1a4c2bc659bdafe50097c6a0e9921cbbf9ee1 /src/event.js
parent60d3ad099f3ee1a39b401d12405dba9e4d7e5da2 (diff)
parent04e21b18c30d546ed6a16b279504a2b58b503541 (diff)
downloadsvg.js-408940add58e81e7879098682e94504a8cf3a734.tar.gz
svg.js-408940add58e81e7879098682e94504a8cf3a734.zip
Merge branch 'master' into 3.0.0
# Conflicts - all resolved: # dist/svg.js # dist/svg.min.js # package.json # spec/SpecRunner.html # spec/spec/boxes.js # spec/spec/element.js # spec/spec/image.js # spec/spec/svg.js # src/boxes.js # src/flatten.js # src/image.js # src/polyfill.js # src/style.js # src/svg.js
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
+})