Browse Source

added option to setOptions to avoid resetting view.

css_transitions
Alex de Mulder 10 years ago
parent
commit
536c2220df
4 changed files with 30 additions and 11 deletions
  1. +7
    -0
      HISTORY.md
  2. +11
    -5
      dist/vis.js
  3. +2
    -2
      docs/graph.html
  4. +10
    -4
      src/graph/Graph.js

+ 7
- 0
HISTORY.md View File

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

+ 11
- 5
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 1.0.2-SNAPSHOT
* @date 2014-05-13
* @date 2014-05-20
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -16046,9 +16046,13 @@ Graph.prototype.setData = function(data, disableStart) {
/**
* Set options
* @param {Object} options
* @param {Boolean} [initializeView] | set zoom and translation to default.
*/
Graph.prototype.setOptions = function (options) {
Graph.prototype.setOptions = function (options, initializeView) {
if (options) {
if (initializeView === undefined) {
initializeView = true;
}
var prop;
// retrieve parameter values
if (options.width !== undefined) {this.width = options.width;}
@ -16275,9 +16279,11 @@ Graph.prototype.setOptions = function (options) {
// bind keys. If disabled, this will not do anything;
this._createKeyBinds();
this.setSize(this.width, this.height);
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
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
- 2
docs/graph.html View File

@ -2041,10 +2041,10 @@ var options: {
</tr>
<tr>
<td>setOptions(options)</td>
<td>setOptions(options,[initializeView])</td>
<td>none</td>
<td>Set options for the graph. The available options are described in
the section <a href="#Configuration_options">Configuration Options</a>.
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 is ment when changing the options of an already initialized graph.
</td>
</tr>

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

@ -502,9 +502,13 @@ Graph.prototype.setData = function(data, disableStart) {
/**
* Set options
* @param {Object} options
* @param {Boolean} [initializeView] | set zoom and translation to default.
*/
Graph.prototype.setOptions = function (options) {
Graph.prototype.setOptions = function (options, initializeView) {
if (options) {
if (initializeView === undefined) {
initializeView = true;
}
var prop;
// retrieve parameter values
if (options.width !== undefined) {this.width = options.width;}
@ -731,9 +735,11 @@ Graph.prototype.setOptions = function (options) {
// bind keys. If disabled, this will not do anything;
this._createKeyBinds();
this.setSize(this.width, this.height);
this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2);
this._setScale(1);
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