|
157 | 157 | return curve(d.path); // 0.8 |
158 | 158 | } |
159 | 159 |
|
160 | | -function drag(n) { |
161 | | - var active = null; |
162 | | - n.on("mouseover", function(d) { if (d != active) d.fixed = true; }) |
163 | | - .on("mouseout", function(d) { if (d != active) d.fixed = false; }) |
164 | | - .on("mousedown", function(d) { |
165 | | - if (d3.event.preventDefault) { d3.event.preventDefault(); } |
166 | | - active = d; |
167 | | - |
168 | | - // unregister drag listeners |
169 | | - body.on("mouseup", function(d) { |
170 | | - active = null; |
171 | | - body.on("mouseup", noop) |
172 | | - .on("mousemove", noop); |
173 | | - }); |
174 | | - |
175 | | - // update node position on drag |
176 | | - body.on("mousemove", function() { |
177 | | - if (active == null) return false; |
178 | | - var m = d3.svg.mouse(vis[0][0]); |
179 | | - active.x = m[0]; |
180 | | - active.y = m[1]; |
181 | | - force.resume(); // restart annealing |
182 | | - }); |
183 | | - |
184 | | - return false; |
185 | | - }); |
186 | | -} |
187 | | - |
188 | 160 | // -------------------------------------------------------- |
189 | 161 |
|
190 | 162 | var body = d3.select("body"); |
|
251 | 223 | .attr("r", function(d) { return d.size ? d.size + dr : dr+1; }) |
252 | 224 | .attr("cx", function(d) { return d.x; }) |
253 | 225 | .attr("cy", function(d) { return d.y; }) |
254 | | - .call(drag) |
255 | 226 | .on("dblclick", function(d) { |
256 | 227 | if (d.size) { expand[d.group] = true; init(); } |
257 | 228 | }); |
258 | | - node = nodeg.selectAll("circle.node"); |
| 229 | + |
| 230 | + node = nodeg.selectAll("circle.node") |
| 231 | + .call(force.drag); |
259 | 232 |
|
260 | 233 | force.on("tick", function() { |
261 | 234 | if (!hull.empty()) { |
|
0 commit comments