source: node_modules/d3-transition/src/transition/on.js@ a762898

Last change on this file since a762898 was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 856 bytes
RevLine 
[e4c61dd]1import {get, set, init} from "./schedule.js";
2
3function start(name) {
4 return (name + "").trim().split(/^|\s+/).every(function(t) {
5 var i = t.indexOf(".");
6 if (i >= 0) t = t.slice(0, i);
7 return !t || t === "start";
8 });
9}
10
11function onFunction(id, name, listener) {
12 var on0, on1, sit = start(name) ? init : set;
13 return function() {
14 var schedule = sit(this, id),
15 on = schedule.on;
16
17 // If this node shared a dispatch with the previous node,
18 // just assign the updated shared dispatch and we’re done!
19 // Otherwise, copy-on-write.
20 if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
21
22 schedule.on = on1;
23 };
24}
25
26export default function(name, listener) {
27 var id = this._id;
28
29 return arguments.length < 2
30 ? get(this.node(), id).on.on(name)
31 : this.each(onFunction(id, name, listener));
32}
Note: See TracBrowser for help on using the repository browser.