Browse Source

Merge pull request #562 from pavlos256/fix_hover_popup_discrepancy

Select the last (top) overlapping object when showing the popup
v3_develop
Alex 10 years ago
parent
commit
683d320e7f
1 changed files with 16 additions and 6 deletions
  1. +16
    -6
      lib/network/Network.js

+ 16
- 6
lib/network/Network.js View File

@ -1336,34 +1336,44 @@ Network.prototype._checkShowPopup = function (pointer) {
if (this.popupObj == undefined) {
// search the nodes for overlap, select the top one in case of multiple nodes
var nodes = this.nodes;
var overlappingNodes = [];
for (id in nodes) {
if (nodes.hasOwnProperty(id)) {
var node = nodes[id];
if (node.isOverlappingWith(obj)) {
if (node.getTitle() !== undefined) {
this.popupObj = node;
break;
overlappingNodes.push(id);
}
// if you hover over a node, the title of the edge is not supposed to be shown.
nodeUnderCursor = true;
}
}
}
if (overlappingNodes.length > 0) {
// if there are overlapping nodes, select the last one, this is the
// one which is drawn on top of the others
this.popupObj = this.nodes[overlappingNodes[overlappingNodes.length - 1]];
// if you hover over a node, the title of the edge is not supposed to be shown.
nodeUnderCursor = true;
}
}
if (this.popupObj === undefined && nodeUnderCursor == false) {
// search the edges for overlap
var edges = this.edges;
var overlappingEdges = [];
for (id in edges) {
if (edges.hasOwnProperty(id)) {
var edge = edges[id];
if (edge.connected && (edge.getTitle() !== undefined) &&
edge.isOverlappingWith(obj)) {
this.popupObj = edge;
break;
overlappingEdges.push(id);
}
}
}
if (overlappingEdges.length > 0) {
this.popupObj = this.edges[overlappingEdges[overlappingEdges.length - 1]];
}
}
if (this.popupObj) {

Loading…
Cancel
Save