|
|
@ -184,23 +184,26 @@ class InteractionHandler { |
|
|
|
else { |
|
|
|
selected = this.selectionHandler.selectOnPoint(pointer); |
|
|
|
} |
|
|
|
let selectedEdges = this.selectionHandler._getSelectedEdgeCount(); |
|
|
|
let selectedNodes = this.selectionHandler._getSelectedNodeCount(); |
|
|
|
let selectedEdgesCount = this.selectionHandler._getSelectedEdgeCount(); |
|
|
|
let selectedNodesCount = this.selectionHandler._getSelectedNodeCount(); |
|
|
|
let currentSelection = this.selectionHandler.getSelection(); |
|
|
|
|
|
|
|
if (selectedNodes - previouslySelectedNodeCount > 0) { // node was selected
|
|
|
|
let {nodesChanges, edgesChanges} = this._determineIfDifferent(previousSelection, currentSelection); |
|
|
|
|
|
|
|
if (selectedNodesCount - previouslySelectedNodeCount > 0 || (selectedNodesCount === previouslySelectedNodeCount && nodesChanges === true)) { // node was selected
|
|
|
|
this.selectionHandler._generateClickEvent('selectNode', event, pointer); |
|
|
|
selected = true; |
|
|
|
} |
|
|
|
else if (selectedNodes - previouslySelectedNodeCount < 0) { // node was deselected
|
|
|
|
else if (selectedNodesCount - previouslySelectedNodeCount < 0) { // node was deselected
|
|
|
|
this.selectionHandler._generateClickEvent('deselectNode', event, pointer, previousSelection); |
|
|
|
selected = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (selectedEdges - previouslySelectedEdgeCount > 0) { // node was selected
|
|
|
|
if (selectedEdgesCount - previouslySelectedEdgeCount > 0|| (selectedEdgesCount === previouslySelectedEdgeCount && edgesChanges === true)) { // node was selected
|
|
|
|
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); |
|
|
|
selected = true; |
|
|
|
} |
|
|
|
else if (selectedEdges - previouslySelectedEdgeCount < 0) { // node was deselected
|
|
|
|
else if (selectedEdgesCount - previouslySelectedEdgeCount < 0) { // node was deselected
|
|
|
|
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection); |
|
|
|
selected = true; |
|
|
|
} |
|
|
@ -211,6 +214,42 @@ class InteractionHandler { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* This function checks if the nodes and edges previously selected have changed. |
|
|
|
* @param previousSelection |
|
|
|
* @param currentSelection |
|
|
|
* @returns {{nodesChanges: boolean, edgesChanges: boolean}} |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_determineIfDifferent(previousSelection,currentSelection) { |
|
|
|
let nodesChanges = false; |
|
|
|
let edgesChanges = false; |
|
|
|
|
|
|
|
for (let i = 0; i < previousSelection.nodes.length; i++) { |
|
|
|
if (currentSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
|
nodesChanges = true; |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < currentSelection.nodes.length; i++) { |
|
|
|
if (previousSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
|
nodesChanges = true; |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < previousSelection.edges.length; i++) { |
|
|
|
if (currentSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
|
edgesChanges = true; |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < currentSelection.edges.length; i++) { |
|
|
|
if (previousSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
|
edgesChanges = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return {nodesChanges, edgesChanges}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* This function is called by onDragStart. |
|
|
|
* It is separated out because we can then overload it for the datamanipulation system. |
|
|
|