Browse Source

added dragNodes option. Renamed dragGraph option.

css_transitions
Alex de Mulder 10 years ago
parent
commit
aa52bdd84b
2 changed files with 15 additions and 5 deletions
  1. +9
    -1
      docs/graph.html
  2. +6
    -4
      src/graph/Graph.js

+ 9
- 1
docs/graph.html View File

@ -857,13 +857,21 @@ var options = {
</td> </td>
</tr> </tr>
<tr> <tr>
<td>moveable</td>
<td>dragGraph</td>
<td>Boolean</td> <td>Boolean</td>
<td>true</td> <td>true</td>
<td> <td>
Toggle if the graph can be dragged. This will not affect the dragging of nodes. Toggle if the graph can be dragged. This will not affect the dragging of nodes.
</td> </td>
</tr> </tr>
<tr>
<td>dragNodes</td>
<td>Boolean</td>
<td>true</td>
<td>
Toggle if the nodes can be dragged. This will not affect the dragging of the graph.
</td>
</tr>
<tr> <tr>
<td><a href="#Navigation_controls">navigation</a></td> <td><a href="#Navigation_controls">navigation</a></td>

+ 6
- 4
src/graph/Graph.js View File

@ -186,7 +186,8 @@ function Graph (container, data, options) {
background: '#FFFFC6' background: '#FFFFC6'
} }
}, },
moveable: true,
dragGraph: true,
dragNodes: true,
zoomable: true, zoomable: true,
hover: false hover: false
}; };
@ -529,7 +530,8 @@ Graph.prototype.setOptions = function (options) {
if (options.freezeForStabilization !== undefined) {this.constants.freezeForStabilization = options.freezeForStabilization;} if (options.freezeForStabilization !== undefined) {this.constants.freezeForStabilization = options.freezeForStabilization;}
if (options.configurePhysics !== undefined){this.constants.configurePhysics = options.configurePhysics;} if (options.configurePhysics !== undefined){this.constants.configurePhysics = options.configurePhysics;}
if (options.stabilizationIterations !== undefined) {this.constants.stabilizationIterations = options.stabilizationIterations;} 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.zoomable !== undefined) {this.constants.zoomable = options.zoomable;}
if (options.hover !== undefined) {this.constants.hover = options.hover;} if (options.hover !== undefined) {this.constants.hover = options.hover;}
@ -956,7 +958,7 @@ Graph.prototype._handleOnDrag = function(event) {
var me = this, var me = this,
drag = this.drag, drag = this.drag,
selection = drag.selection; selection = drag.selection;
if (selection && selection.length) {
if (selection && selection.length && this.constants.dragNodes == true) {
// calculate delta's and new location // calculate delta's and new location
var deltaX = pointer.x - drag.pointer.x, var deltaX = pointer.x - drag.pointer.x,
deltaY = pointer.y - drag.pointer.y; deltaY = pointer.y - drag.pointer.y;
@ -981,7 +983,7 @@ Graph.prototype._handleOnDrag = function(event) {
} }
} }
else { else {
if (this.constants.moveable == true) {
if (this.constants.dragGraph == true) {
// move the graph // move the graph
var diffX = pointer.x - this.drag.pointer.x; var diffX = pointer.x - this.drag.pointer.x;
var diffY = pointer.y - this.drag.pointer.y; var diffY = pointer.y - this.drag.pointer.y;

Loading…
Cancel
Save