Browse Source

added startStabilization event

v3_develop
Alex de Mulder 10 years ago
parent
commit
ea78ec883c
5 changed files with 2017 additions and 1992 deletions
  1. +1
    -0
      HISTORY.md
  2. +1991
    -1984
      dist/vis.js
  3. +14
    -7
      docs/network.html
  4. +4
    -1
      examples/network/02_random_nodes.html
  5. +7
    -0
      lib/network/Network.js

+ 1
- 0
HISTORY.md View File

@ -32,6 +32,7 @@ http://visjs.org
- Fixed possible cause of freezing graph when animating.
- Added locked to focusOnNode and releaseNode().
- Fixed minor bug in positioning of fontFill of nodes with certain shapes.
- Added startStabilization event.
## 2014-10-11, version 3.4.1

+ 1991
- 1984
dist/vis.js
File diff suppressed because it is too large
View File


+ 14
- 7
docs/network.html View File

@ -2448,13 +2448,20 @@ network.off('select', onSelect);
</ul>
</td>
</tr>
<tr>
<td>stabilized</td>
<td>Fired every time the network has been stabilized. This event can be used to trigger the .storePositions() function after stabilization. Fired with an object having the following properties:</td>
<td>
<ul>
<li><code>iterations</code>: number of iterations used to stabilize</li>
</ul>
<tr>
<td>startStabilization</td>
<td>Fired once when the network starts the physics calculation. This ends with the stabilized event.
<td>
none
</td>
</tr>
<tr>
<td>stabilized</td>
<td>Fired every time the network has been stabilized. This event can be used to trigger the .storePositions() function after stabilization. Fired with an object having the following properties:</td>
<td>
<ul>
<li><code>iterations</code>: number of iterations used to stabilize</li>
</ul>
</td>
</tr>
<tr>

+ 4
- 1
examples/network/02_random_nodes.html View File

@ -83,7 +83,10 @@
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes;
});
network.on('stabilized', function (params) {
document.getElementById('stabilization').innerHTML = 'Stabilization took ' + params.iterations + ' iterations.';
document.getElementById('stabilization').innerHTML = 'Stabilization took ' + params.iterations + ' iterations.';
});
network.on('startStabilization', function (params) {
document.getElementById('stabilization').innerHTML = 'Stabilizing...';
});
}

+ 7
- 0
lib/network/Network.js View File

@ -267,6 +267,7 @@ function Network (container, data, options) {
// other vars
this.freezeSimulation = false;// freeze the simulation
this.cachedFunctions = {};
this.startedStabilization = false;
this.stabilized = false;
this.stabilizationIterations = null;
@ -2093,6 +2094,11 @@ if (typeof window !== 'undefined') {
*/
Network.prototype.start = function() {
if (this.moving == true || this.xIncrement != 0 || this.yIncrement != 0 || this.zoomIncrement != 0) {
if (this.startedStabilization == false) {
this.emit("startStabilization");
this.startedStabilization = true;
}
if (!this.timer) {
var ua = navigator.userAgent.toLowerCase();
@ -2126,6 +2132,7 @@ Network.prototype.start = function() {
iterations: me.stabilizationIterations
};
me.stabilizationIterations = 0;
me.startedStabilization = false;
setTimeout(function () {
me.emit("stabilized", params);
}, 0);

Loading…
Cancel
Save