aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
blob: a9b1cfca607e7d9f28153a2fb751fb57ea4c7469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// ### Manage events on elements

//     rect.click(function() {
//       this.fill({ color: '#f06' });
//     });
[ 'click',
  'dblclick',
  'mousedown',
  'mouseup',
  'mouseover',
  'mouseout',
  'mousemove',
  'touchstart',
  'touchend',
  'touchmove',
  'touchcancel' ].forEach(function(event) {
  
  /* 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] = function() {
      return f.apply(self, arguments);
    };
    
    return this;
  };
});