summaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-01-04 19:12:16 +0100
committerwout <wout@impinc.co.uk>2013-01-04 19:12:16 +0100
commit2380c67d4ddded556617760b4b3cb38a1d7758e2 (patch)
treec0bd5ee57a4c83e5d8860becba7766188344eda3 /src/event.js
parent40de19951d0a4218ee2625fa9a1a69f04e79692d (diff)
downloadsvg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.tar.gz
svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.zip
Made code more readable and included docs
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/event.js b/src/event.js
index 32c2be2..a9b1cfc 100644
--- a/src/event.js
+++ b/src/event.js
@@ -1,4 +1,8 @@
+// ### Manage events on elements
+// rect.click(function() {
+// this.fill({ color: '#f06' });
+// });
[ 'click',
'dblclick',
'mousedown',
@@ -9,18 +13,17 @@
'touchstart',
'touchend',
'touchmove',
- 'touchcancel' ].forEach(function(e) {
+ 'touchcancel' ].forEach(function(event) {
- // add event to SVG.Elment
- SVG.Element.prototype[e] = function(f) {
- var s = this;
+ /* 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' + e] = function() {
- return f.apply(s, arguments);
+ /* bind event to element rather than element node */
+ this.node['on' + event] = function() {
+ return f.apply(self, arguments);
};
-
- // return self
+
return this;
};
});