Browse Source

fixed dragStart, dragging and dragEnd events when nodes are selected but the viewport is dragged

flowchartTest
AlexDM0 9 years ago
parent
commit
3c34a7dd78
5 changed files with 28804 additions and 28785 deletions
  1. +28770
    -28760
      dist/vis.js
  2. +1
    -1
      dist/vis.map
  3. +18
    -18
      dist/vis.min.js
  4. +7
    -4
      lib/network/modules/InteractionHandler.js
  5. +8
    -2
      lib/network/modules/SelectionHandler.js

+ 28770
- 28760
dist/vis.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 18
- 18
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 7
- 4
lib/network/modules/InteractionHandler.js View File

@ -318,7 +318,7 @@ class InteractionHandler {
} }
else { else {
// fallback if no node is selected and thus the view is dragged. // fallback if no node is selected and thus the view is dragged.
this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer);
this.selectionHandler._generateClickEvent('dragStart', event, this.drag.pointer, undefined, true);
} }
} }
@ -337,10 +337,10 @@ class InteractionHandler {
let pointer = this.getPointer(event.center); let pointer = this.getPointer(event.center);
this.selectionHandler._generateClickEvent('dragging', event, pointer);
let selection = this.drag.selection; let selection = this.drag.selection;
if (selection && selection.length && this.options.dragNodes === true) { if (selection && selection.length && this.options.dragNodes === true) {
this.selectionHandler._generateClickEvent('dragging', event, pointer);
// calculate delta's and new location // calculate delta's and new location
let deltaX = pointer.x - this.drag.pointer.x; let deltaX = pointer.x - this.drag.pointer.x;
let deltaY = pointer.y - this.drag.pointer.y; let deltaY = pointer.y - this.drag.pointer.y;
@ -364,6 +364,8 @@ class InteractionHandler {
else { else {
// move the network // move the network
if (this.options.dragView === true) { 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 the drag was not started properly because the click started outside the network div, start it now.
if (this.drag.pointer === undefined) { if (this.drag.pointer === undefined) {
this._handleDragStart(event); this._handleDragStart(event);
@ -387,6 +389,7 @@ class InteractionHandler {
this.drag.dragging = false; this.drag.dragging = false;
let selection = this.drag.selection; let selection = this.drag.selection;
if (selection && selection.length) { if (selection && selection.length) {
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center));
selection.forEach(function (s) { selection.forEach(function (s) {
// restore original xFixed and yFixed // restore original xFixed and yFixed
s.node.options.fixed.x = s.xFixed; s.node.options.fixed.x = s.xFixed;
@ -395,9 +398,9 @@ class InteractionHandler {
this.body.emitter.emit('startSimulation'); this.body.emitter.emit('startSimulation');
} }
else { else {
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center), undefined, true);
this.body.emitter.emit('_requestRedraw'); this.body.emitter.emit('_requestRedraw');
} }
this.selectionHandler._generateClickEvent('dragEnd', event, this.getPointer(event.center));
} }

+ 8
- 2
lib/network/modules/SelectionHandler.js View File

@ -74,8 +74,14 @@ class SelectionHandler {
return selectionChanged; return selectionChanged;
} }
_generateClickEvent(eventType, event, pointer, oldSelection) {
let properties = this.getSelection();
_generateClickEvent(eventType, event, pointer, oldSelection, emptySelection = false) {
let properties;
if (emptySelection === true) {
properties = {nodes:[], edges:[]};
}
else {
properties = this.getSelection();
}
properties['pointer'] = { properties['pointer'] = {
DOM: {x: pointer.x, y: pointer.y}, DOM: {x: pointer.x, y: pointer.y},
canvas: this.canvas.DOMtoCanvas(pointer) canvas: this.canvas.DOMtoCanvas(pointer)

Loading…
Cancel
Save