|
|
@ -282,8 +282,6 @@ class InteractionHandler { |
|
|
|
this.drag.translation = util.extend({},this.body.view.translation); // copy the object
|
|
|
|
this.drag.nodeId = undefined; |
|
|
|
|
|
|
|
this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer); |
|
|
|
|
|
|
|
if (node !== undefined && this.options.dragNodes === true) { |
|
|
|
this.drag.nodeId = node.id; |
|
|
|
// select the clicked node if not yet selected
|
|
|
@ -292,6 +290,9 @@ class InteractionHandler { |
|
|
|
this.selectionHandler.selectObject(node); |
|
|
|
} |
|
|
|
|
|
|
|
// after select to contain the node
|
|
|
|
this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer); |
|
|
|
|
|
|
|
let selection = this.selectionHandler.selectionObj.nodes; |
|
|
|
// create an array with the selected nodes and their original location and status
|
|
|
|
for (let nodeId in selection) { |
|
|
@ -315,6 +316,10 @@ class InteractionHandler { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
// fallback if no node is selected and thus the view is dragged.
|
|
|
|
this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer, undefined, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -332,10 +337,10 @@ class InteractionHandler { |
|
|
|
|
|
|
|
let pointer = this.getPointer(event.center); |
|
|
|
|
|
|
|
this.selectionHandler._generateClickEvent('dragging', event, pointer); |
|
|
|
|
|
|
|
let selection = this.drag.selection; |
|
|
|
if (selection && selection.length && this.options.dragNodes === true) { |
|
|
|
this.selectionHandler._generateClickEvent('dragging', event, pointer); |
|
|
|
|
|
|
|
// calculate delta's and new location
|
|
|
|
let deltaX = pointer.x - this.drag.pointer.x; |
|
|
|
let deltaY = pointer.y - this.drag.pointer.y; |
|
|
@ -359,6 +364,8 @@ class InteractionHandler { |
|
|
|
else { |
|
|
|
// move the network
|
|
|
|
if (this.options.dragView === true) { |
|
|
|
this.selectionHandler._generateClickEvent('dragging', event, pointer, undefined, true); |
|
|
|
|
|
|
|
// if the drag was not started properly because the click started outside the network div, start it now.
|
|
|
|
if (this.drag.pointer === undefined) { |
|
|
|
this._handleDragStart(event); |
|
|
@ -382,6 +389,7 @@ class InteractionHandler { |
|
|
|
this.drag.dragging = false; |
|
|
|
let selection = this.drag.selection; |
|
|
|
if (selection && selection.length) { |
|
|
|
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center)); |
|
|
|
selection.forEach(function (s) { |
|
|
|
// restore original xFixed and yFixed
|
|
|
|
s.node.options.fixed.x = s.xFixed; |
|
|
@ -390,9 +398,9 @@ class InteractionHandler { |
|
|
|
this.body.emitter.emit('startSimulation'); |
|
|
|
} |
|
|
|
else { |
|
|
|
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center), undefined, true); |
|
|
|
this.body.emitter.emit('_requestRedraw'); |
|
|
|
} |
|
|
|
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|