[BUGFIX] Select correct goto link

This commit is contained in:
Geno 2017-11-01 11:43:20 +01:00 committed by Xaver Maierhofer
parent 1ec81fd45c
commit 9f95fa9c95
2 changed files with 10 additions and 11 deletions

View File

@ -242,12 +242,9 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
self.gotoNode = function gotoNode(d) {
moveTo(function calcToNode() {
for (var i = 0; i < intNodes.length; i++) {
var n = intNodes[i];
if (n.o.node_id !== d.node_id) {
continue;
}
draw.setHighlight({ type: 'node', o: n.o });
draw.setHighlight({ type: 'node', id: d.node_id });
var n = dictNodes[d.node_id];
if (n) {
return [n.x, n.y, (ZOOM_MAX + 1) / 2];
}
return [0, 0, (ZOOM_MIN + 1) / 2];
@ -256,9 +253,11 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
self.gotoLink = function gotoLink(d) {
moveTo(function calcToLink() {
draw.setHighlight({ type: 'link', o: d });
for (var i = 0; i < intLinks.length; i++) {
var l = intLinks[i];
draw.setHighlight({ type: 'link', id: d.id });
var l = intLinks.find(function (link) {
return link.o.id === d.id;
});
if (l) {
return [(l.source.x + l.target.x) / 2, (l.source.y + l.target.y) / 2, (ZOOM_MAX / 2) + ZOOM_MIN];
}
return [0, 0, (ZOOM_MIN + 1) / 2];

View File

@ -32,7 +32,7 @@ define(['helper'], function (helper) {
}
function drawHighlightNode(d) {
if (highlight && highlight.type === 'node' && d.o.node_id === highlight.o.node_id) {
if (highlight && highlight.type === 'node' && d.o.node_id === highlight.id) {
ctx.arc(d.x, d.y, NODE_RADIUS * 1.5, 0, 2 * Math.PI);
ctx.fillStyle = highlightColor;
ctx.fill();
@ -41,7 +41,7 @@ define(['helper'], function (helper) {
}
function drawHighlightLink(d, to) {
if (highlight && highlight.type === 'link' && d.o.id === highlight.o.id) {
if (highlight && highlight.type === 'link' && d.o.id === highlight.id) {
ctx.lineTo(to[0], to[1]);
ctx.strokeStyle = highlightColor;
ctx.lineWidth = LINE_RADIUS * 2;