diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2016-03-24 23:44:59 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2016-03-24 23:44:59 +0100 |
commit | 000b071d04d67091c148cbe66e515e63b4b46986 (patch) | |
tree | 433bc79e68b00e06d2c1657b9a0b48e24248b944 /src/event.js | |
parent | 595777968f56ebafc8ab0b25d8605ce258f87c98 (diff) | |
parent | c33e7f6c5b6cd2e4ef595fce65559eb74b8c5e63 (diff) | |
download | svg.js-000b071d04d67091c148cbe66e515e63b4b46986.tar.gz svg.js-000b071d04d67091c148cbe66e515e63b4b46986.zip |
Merge branch '3.0.0' introducing several changes:
- textpath now is a parent element, the lines method of text will return the tspans inside the textpath (#450)
- fx module rewritten to support animation chaining and several other stuff (see docs when commited)
- fixed absolute transformation animations (not perfect but better)
- fixed event listeners which didnt work correctly when identic funtions used
- added `element.is()` which helps to check for the object instance faster (instanceof check)
- added more fx specs
Diffstat (limited to 'src/event.js')
-rw-r--r-- | src/event.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/event.js b/src/event.js index 66cf6c3..e94b6e1 100644 --- a/src/event.js +++ b/src/event.js @@ -30,6 +30,7 @@ // Initialize listeners stack SVG.listeners = [] SVG.handlerMap = [] +SVG.listenerId = 0 // Add event binder in the SVG namespace SVG.on = function(node, event, listener, binding) { @@ -45,8 +46,11 @@ SVG.on = function(node, event, listener, binding) { SVG.listeners[index][ev] = SVG.listeners[index][ev] || {} SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {} + if(!listener._svgjsListenerId) + listener._svgjsListenerId = ++SVG.listenerId + // reference listener - SVG.listeners[index][ev][ns][listener] = l + SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l // add listener node.addEventListener(ev, l, false) @@ -59,8 +63,11 @@ SVG.off = function(node, event, listener) { , ns = event && event.split('.')[1] if(index == -1) return - + if (listener) { + if(typeof listener == 'function') listener = listener._svgjsListenerId + if(!listener) return + // remove listener reference if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) { // remove listener |