diff --git a/HISTORY.md b/HISTORY.md index ea608cea..c427513b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,7 +6,7 @@ http://visjs.org ### Graph -- added option to setOptions to avoid resetting view. +- changes setOptions to avoid resetting view. ## 2014-05-09, version 1.0.1 diff --git a/dist/vis.js b/dist/vis.js index 6ef01017..5c670e0a 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -15755,8 +15755,11 @@ function Graph (container, data, options) { this._loadHierarchySystem(); // apply options + this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2); + this._setScale(1); this.setOptions(options); + // other vars this.freezeSimulation = false;// freeze the simulation this.cachedFunctions = {}; @@ -16048,11 +16051,8 @@ Graph.prototype.setData = function(data, disableStart) { * @param {Object} options * @param {Boolean} [initializeView] | set zoom and translation to default. */ -Graph.prototype.setOptions = function (options, initializeView) { +Graph.prototype.setOptions = function (options) { if (options) { - if (initializeView === undefined) { - initializeView = true; - } var prop; // retrieve parameter values 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; 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(); }; /** diff --git a/docs/graph.html b/docs/graph.html index bf441dbc..b2bcce53 100644 --- a/docs/graph.html +++ b/docs/graph.html @@ -2041,12 +2041,10 @@ var options: { - setOptions(options,[initializeView]) + setOptions(options) none Set options for the graph. The available options are described in - the section Configuration Options. The initializeView 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 Configuration Options. diff --git a/src/graph/Graph.js b/src/graph/Graph.js index 095f93ec..c61f863a 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -211,8 +211,11 @@ function Graph (container, data, options) { this._loadHierarchySystem(); // apply options + this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2); + this._setScale(1); this.setOptions(options); + // other vars this.freezeSimulation = false;// freeze the simulation this.cachedFunctions = {}; @@ -504,11 +507,8 @@ Graph.prototype.setData = function(data, disableStart) { * @param {Object} options * @param {Boolean} [initializeView] | set zoom and translation to default. */ -Graph.prototype.setOptions = function (options, initializeView) { +Graph.prototype.setOptions = function (options) { if (options) { - if (initializeView === undefined) { - initializeView = true; - } var prop; // retrieve parameter values 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; 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(); }; /**