Browse Source

fix : selectEdge was fired even if user clicked on a node

The selectEdge handler is now fired only if user clicked on an edge, in order to select it.
 It's not fired if the node are selected because there are connected to the selected node.
kamadaKawai
JonathanGeoffroy 9 years ago
committed by Jonathan Geoffroy
parent
commit
711b3def94
1 changed files with 8 additions and 10 deletions
  1. +8
    -10
      lib/network/modules/InteractionHandler.js

+ 8
- 10
lib/network/modules/InteractionHandler.js View File

@ -205,21 +205,19 @@ class InteractionHandler {
selected = true; selected = true;
} }
if (selectedEdgesCount - previouslySelectedEdgeCount > 0) { // edge was selected
this.selectionHandler._generateClickEvent('selectEdge', event, pointer);
selected = true;
}
else if (selectedEdgesCount - previouslySelectedEdgeCount < 0) { // edge was deselected
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection);
selected = true;
if (selectedEdgesCount - previouslySelectedEdgeCount < 0 || (selectedEdgesCount === previouslySelectedEdgeCount && edgesChanges === true)) { // edge was deselected
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection);
selected = true;
} }
else if (selectedEdgesCount === previouslySelectedEdgeCount && edgesChanges === true) {
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection);
// Check if the user clicked on an edge
let selectedNode = this.selectionHandler._getSelectedNode();
let selectedEdge = this.selectionHandler._getSelectedEdge();
if (selectedNode === undefined && selectedEdge !== undefined) {
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); this.selectionHandler._generateClickEvent('selectEdge', event, pointer);
selected = true; selected = true;
} }
if (selected === true) { // select or unselect if (selected === true) { // select or unselect
this.selectionHandler._generateClickEvent('select', event, pointer); this.selectionHandler._generateClickEvent('select', event, pointer);
} }

Loading…
Cancel
Save