|
@ -189,7 +189,7 @@ class InteractionHandler { |
|
|
let selectedNodesCount = this.selectionHandler._getSelectedNodeCount(); |
|
|
let selectedNodesCount = this.selectionHandler._getSelectedNodeCount(); |
|
|
let currentSelection = this.selectionHandler.getSelection(); |
|
|
let currentSelection = this.selectionHandler.getSelection(); |
|
|
|
|
|
|
|
|
let {nodesChanges, edgesChanges} = this._determineIfDifferent(previousSelection, currentSelection); |
|
|
|
|
|
|
|
|
let {nodesChanged, edgesChanged} = this._determineIfDifferent(previousSelection, currentSelection); |
|
|
let nodeSelected = false; |
|
|
let nodeSelected = false; |
|
|
|
|
|
|
|
|
if (selectedNodesCount - previouslySelectedNodeCount > 0) { // node was selected
|
|
|
if (selectedNodesCount - previouslySelectedNodeCount > 0) { // node was selected
|
|
@ -197,32 +197,34 @@ class InteractionHandler { |
|
|
selected = true; |
|
|
selected = true; |
|
|
nodeSelected = true; |
|
|
nodeSelected = true; |
|
|
} |
|
|
} |
|
|
else if (selectedNodesCount - previouslySelectedNodeCount < 0) { // node was deselected
|
|
|
|
|
|
|
|
|
else if (nodesChanged === true && selectedNodesCount > 0) { |
|
|
this.selectionHandler._generateClickEvent('deselectNode', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('deselectNode', event, pointer, previousSelection); |
|
|
|
|
|
this.selectionHandler._generateClickEvent('selectNode', event, pointer); |
|
|
|
|
|
nodeSelected = true; |
|
|
selected = true; |
|
|
selected = true; |
|
|
} |
|
|
} |
|
|
else if (selectedNodesCount === previouslySelectedNodeCount && nodesChanges === true) { |
|
|
|
|
|
|
|
|
else if (selectedNodesCount - previouslySelectedNodeCount < 0) { // node was deselected
|
|
|
this.selectionHandler._generateClickEvent('deselectNode', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('deselectNode', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('selectNode', event, pointer); |
|
|
|
|
|
nodeSelected = true; |
|
|
|
|
|
selected = true; |
|
|
selected = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handle the selected edges
|
|
|
// handle the selected edges
|
|
|
if (selectedEdgesCount - previouslySelectedEdgeCount > 0 && nodeSelected === false) { // edge was selected
|
|
|
if (selectedEdgesCount - previouslySelectedEdgeCount > 0 && nodeSelected === false) { // edge was selected
|
|
|
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); |
|
|
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); |
|
|
selected = true; |
|
|
selected = true; |
|
|
} |
|
|
} |
|
|
else if (selectedEdgesCount - previouslySelectedEdgeCount < 0) { // edge was deselected
|
|
|
|
|
|
|
|
|
else if (selectedEdgesCount > 0 && edgesChanged === true) { |
|
|
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection); |
|
|
|
|
|
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); |
|
|
selected = true; |
|
|
selected = true; |
|
|
} |
|
|
} |
|
|
else if (selectedEdgesCount === previouslySelectedEdgeCount && edgesChanges === true) { |
|
|
|
|
|
|
|
|
else if (selectedEdgesCount - previouslySelectedEdgeCount < 0) { // edge was deselected
|
|
|
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('deselectEdge', event, pointer, previousSelection); |
|
|
this.selectionHandler._generateClickEvent('selectEdge', event, pointer); |
|
|
|
|
|
selected = true; |
|
|
selected = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fire the select event if anything has been selected or deselected
|
|
|
// fire the select event if anything has been selected or deselected
|
|
|
if (selected === true) { // select or unselect
|
|
|
if (selected === true) { // select or unselect
|
|
|
this.selectionHandler._generateClickEvent('select', event, pointer); |
|
|
this.selectionHandler._generateClickEvent('select', event, pointer); |
|
@ -234,35 +236,35 @@ class InteractionHandler { |
|
|
* This function checks if the nodes and edges previously selected have changed. |
|
|
* This function checks if the nodes and edges previously selected have changed. |
|
|
* @param previousSelection |
|
|
* @param previousSelection |
|
|
* @param currentSelection |
|
|
* @param currentSelection |
|
|
* @returns {{nodesChanges: boolean, edgesChanges: boolean}} |
|
|
|
|
|
|
|
|
* @returns {{nodesChanged: boolean, edgesChanged: boolean}} |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_determineIfDifferent(previousSelection,currentSelection) { |
|
|
_determineIfDifferent(previousSelection,currentSelection) { |
|
|
let nodesChanges = false; |
|
|
|
|
|
let edgesChanges = false; |
|
|
|
|
|
|
|
|
let nodesChanged = false; |
|
|
|
|
|
let edgesChanged = false; |
|
|
|
|
|
|
|
|
for (let i = 0; i < previousSelection.nodes.length; i++) { |
|
|
for (let i = 0; i < previousSelection.nodes.length; i++) { |
|
|
if (currentSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
if (currentSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
nodesChanges = true; |
|
|
|
|
|
|
|
|
nodesChanged = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < currentSelection.nodes.length; i++) { |
|
|
for (let i = 0; i < currentSelection.nodes.length; i++) { |
|
|
if (previousSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
if (previousSelection.nodes.indexOf(previousSelection.nodes[i]) === -1) { |
|
|
nodesChanges = true; |
|
|
|
|
|
|
|
|
nodesChanged = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < previousSelection.edges.length; i++) { |
|
|
for (let i = 0; i < previousSelection.edges.length; i++) { |
|
|
if (currentSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
if (currentSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
edgesChanges = true; |
|
|
|
|
|
|
|
|
edgesChanged = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < currentSelection.edges.length; i++) { |
|
|
for (let i = 0; i < currentSelection.edges.length; i++) { |
|
|
if (previousSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
if (previousSelection.edges.indexOf(previousSelection.edges[i]) === -1) { |
|
|
edgesChanges = true; |
|
|
|
|
|
|
|
|
edgesChanged = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return {nodesChanges, edgesChanges}; |
|
|
|
|
|
|
|
|
return {nodesChanged, edgesChanged}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|