forked from AlyonaShadrina/react-graph-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
54 lines (42 loc) · 1.46 KB
/
events.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tick = exports.dragended = exports.dragged = exports.dragstarted = exports.dragsubject = void 0;
var _d3Selection = require("d3-selection");
var dragsubject = function dragsubject(simulation) {
return simulation.find(_d3Selection.event.x, _d3Selection.event.y);
};
exports.dragsubject = dragsubject;
var dragstarted = function dragstarted(simulation) {
if (!_d3Selection.event.active) simulation.alphaTarget(0.3).restart();
_d3Selection.event.subject.fx = _d3Selection.event.subject.x;
_d3Selection.event.subject.fy = _d3Selection.event.subject.y;
};
exports.dragstarted = dragstarted;
var dragged = function dragged() {
_d3Selection.event.subject.fx = _d3Selection.event.x;
_d3Selection.event.subject.fy = _d3Selection.event.y;
};
exports.dragged = dragged;
var dragended = function dragended(simulation) {
if (!_d3Selection.event.active) simulation.alphaTarget(0);
_d3Selection.event.subject.fx = null;
_d3Selection.event.subject.fy = null;
};
exports.dragended = dragended;
var tick = function tick(node, link) {
link.attr("x1", function (d) {
return d.source.x;
}).attr("y1", function (d) {
return d.source.y;
}).attr("x2", function (d) {
return d.target.x;
}).attr("y2", function (d) {
return d.target.y;
});
node.style('transform', function (d) {
return "translate(".concat(d.x, "px, ").concat(d.y, "px)");
});
};
exports.tick = tick;