aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
blob: ca1d29045bdf3e30a05e4f539fc97850259d3a17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var eventTypes = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove'];

// generate events
for (var i = eventTypes.length - 1; i >= 0; i--) {
  var t = eventTypes[i];
  
  // add event to SVG.Elment
  SVG.Element.prototype[t] = function(f) {
    var e = this;
    
    // bind event to element rather than element node
    this.node['on' + t] = function() {
      return f.apply(e, arguments);
    };
    
    // return self
    return this;
  };
};