Browse Source

restored setOptions, removed reset of view.

css_transitions
Alex de Mulder 10 years ago
parent
commit
abea9085a5
4 changed files with 17 additions and 25 deletions
  1. +1
    -1
      HISTORY.md
  2. +7
    -10
      dist/vis.js
  3. +2
    -4
      docs/graph.html
  4. +7
    -10
      src/graph/Graph.js

+ 1
- 1
HISTORY.md View File

@ -6,7 +6,7 @@ http://visjs.org
### Graph ### Graph
- added option to setOptions to avoid resetting view.
- changes setOptions to avoid resetting view.
## 2014-05-09, version 1.0.1 ## 2014-05-09, version 1.0.1

+ 7
- 10
dist/vis.js View File

@ -15755,8 +15755,11 @@ function Graph (container, data, options) {
this._loadHierarchySystem(); this._loadHierarchySystem();
// apply options // apply options
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
this.setOptions(options); this.setOptions(options);
// other vars // other vars
this.freezeSimulation = false;// freeze the simulation this.freezeSimulation = false;// freeze the simulation
this.cachedFunctions = {}; this.cachedFunctions = {};
@ -16048,11 +16051,8 @@ Graph.prototype.setData = function(data, disableStart) {
* @param {Object} options * @param {Object} options
* @param {Boolean} [initializeView] | set zoom and translation to default. * @param {Boolean} [initializeView] | set zoom and translation to default.
*/ */
Graph.prototype.setOptions = function (options, initializeView) {
Graph.prototype.setOptions = function (options) {
if (options) { if (options) {
if (initializeView === undefined) {
initializeView = true;
}
var prop; var prop;
// retrieve parameter values // retrieve parameter values
if (options.width !== undefined) {this.width = options.width;} if (options.width !== undefined) {this.width = options.width;}
@ -16278,13 +16278,10 @@ Graph.prototype.setOptions = function (options, initializeView) {
// bind keys. If disabled, this will not do anything; // bind keys. If disabled, this will not do anything;
this._createKeyBinds(); this._createKeyBinds();
this.setSize(this.width, this.height);
this.moving = true;
this.start();
if (initializeView == true) {
this.setSize(this.width, this.height);
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
}
this._redraw();
}; };
/** /**

+ 2
- 4
docs/graph.html View File

@ -2041,12 +2041,10 @@ var options: {
</tr> </tr>
<tr> <tr>
<td>setOptions(options,[initializeView])</td>
<td>setOptions(options)</td>
<td>none</td> <td>none</td>
<td>Set options for the graph. The available options are described in <td>Set options for the graph. The available options are described in
the section <a href="#Configuration_options">Configuration Options</a>. The <code>initializeView</code> boolean parameter is
optional and can be used to avoid the resetting of the view when loading the options.
This can be used when changing the options of an already initialized graph.
the section <a href="#Configuration_options">Configuration Options</a>.
</td> </td>
</tr> </tr>

+ 7
- 10
src/graph/Graph.js View File

@ -211,8 +211,11 @@ function Graph (container, data, options) {
this._loadHierarchySystem(); this._loadHierarchySystem();
// apply options // apply options
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
this.setOptions(options); this.setOptions(options);
// other vars // other vars
this.freezeSimulation = false;// freeze the simulation this.freezeSimulation = false;// freeze the simulation
this.cachedFunctions = {}; this.cachedFunctions = {};
@ -504,11 +507,8 @@ Graph.prototype.setData = function(data, disableStart) {
* @param {Object} options * @param {Object} options
* @param {Boolean} [initializeView] | set zoom and translation to default. * @param {Boolean} [initializeView] | set zoom and translation to default.
*/ */
Graph.prototype.setOptions = function (options, initializeView) {
Graph.prototype.setOptions = function (options) {
if (options) { if (options) {
if (initializeView === undefined) {
initializeView = true;
}
var prop; var prop;
// retrieve parameter values // retrieve parameter values
if (options.width !== undefined) {this.width = options.width;} if (options.width !== undefined) {this.width = options.width;}
@ -734,13 +734,10 @@ Graph.prototype.setOptions = function (options, initializeView) {
// bind keys. If disabled, this will not do anything; // bind keys. If disabled, this will not do anything;
this._createKeyBinds(); this._createKeyBinds();
this.setSize(this.width, this.height);
this.moving = true;
this.start();
if (initializeView == true) {
this.setSize(this.width, this.height);
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
}
this._redraw();
}; };
/** /**

Loading…
Cancel
Save