From aa52bdd84b65fc2ccd14c9286e393c881d98f2fa Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Fri, 6 Jun 2014 15:30:15 +0200 Subject: [PATCH 1/2] added dragNodes option. Renamed dragGraph option. --- docs/graph.html | 10 +++++++++- src/graph/Graph.js | 10 ++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/graph.html b/docs/graph.html index 0301c214..20e96ed2 100644 --- a/docs/graph.html +++ b/docs/graph.html @@ -857,13 +857,21 @@ var options = { - moveable + dragGraph Boolean true Toggle if the graph can be dragged. This will not affect the dragging of nodes. + + dragNodes + Boolean + true + + Toggle if the nodes can be dragged. This will not affect the dragging of the graph. + + navigation diff --git a/src/graph/Graph.js b/src/graph/Graph.js index 288aac05..b7581e7a 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -186,7 +186,8 @@ function Graph (container, data, options) { background: '#FFFFC6' } }, - moveable: true, + dragGraph: true, + dragNodes: true, zoomable: true, hover: false }; @@ -529,7 +530,8 @@ Graph.prototype.setOptions = function (options) { if (options.freezeForStabilization !== undefined) {this.constants.freezeForStabilization = options.freezeForStabilization;} if (options.configurePhysics !== undefined){this.constants.configurePhysics = options.configurePhysics;} if (options.stabilizationIterations !== undefined) {this.constants.stabilizationIterations = options.stabilizationIterations;} - if (options.moveable !== undefined) {this.constants.moveable = options.moveable;} + if (options.dragGraph !== undefined) {this.constants.dragGraph = options.dragGraph;} + if (options.dragNodes !== undefined) {this.constants.dragNodes = options.dragNodes;} if (options.zoomable !== undefined) {this.constants.zoomable = options.zoomable;} if (options.hover !== undefined) {this.constants.hover = options.hover;} @@ -956,7 +958,7 @@ Graph.prototype._handleOnDrag = function(event) { var me = this, drag = this.drag, selection = drag.selection; - if (selection && selection.length) { + if (selection && selection.length && this.constants.dragNodes == true) { // calculate delta's and new location var deltaX = pointer.x - drag.pointer.x, deltaY = pointer.y - drag.pointer.y; @@ -981,7 +983,7 @@ Graph.prototype._handleOnDrag = function(event) { } } else { - if (this.constants.moveable == true) { + if (this.constants.dragGraph == true) { // move the graph var diffX = pointer.x - this.drag.pointer.x; var diffY = pointer.y - this.drag.pointer.y; From 89bec935537ba631e4d758c6dbfe971ae64e265e Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Fri, 6 Jun 2014 15:30:56 +0200 Subject: [PATCH 2/2] updated History --- HISTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.md b/HISTORY.md index 4b203627..a69a305a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -17,6 +17,7 @@ http://visjs.org - Fixed error with zero nodes with hierarchical layout. - Added focusOnNode function. - Added hover option. +- Added dragNodes option. Renamed movebale to dragGraph option. - Added hover events (hoverNode, blurNode). ### Graph3D