Sha256: c0e33851ce255238e4d84488311e53ea73137c0172d045b83702ef21a43fbfe2
Contents?: true
Size: 1.04 KB
Versions: 31
Compression:
Stored size: 1.04 KB
Contents
// type can be namespaced, e.g., "click.foo" // listener can be null for removal d3_selectionPrototype.on = function(type, listener, capture) { if (arguments.length < 3) capture = false; // parse the type specifier var name = "__on" + type, i = type.indexOf("."); if (i > 0) type = type.substring(0, i); // if called with only one argument, return the current listener if (arguments.length < 2) return (i = this.node()[name]) && i._; // remove the old event listener, and add the new event listener return this.each(function(d, i) { var node = this; if (node[name]) node.removeEventListener(type, node[name], capture); if (listener) node.addEventListener(type, node[name] = l, capture); // wrapped event listener that preserves i function l(e) { var o = d3.event; // Events can be reentrant (e.g., focus). d3.event = e; try { listener.call(node, node.__data__, i); } finally { d3.event = o; } } // stash the unwrapped listener for retrieval l._ = listener; }); };
Version data entries
31 entries across 31 versions & 2 rubygems