Browse Source

Stabilized event firing repeatedly again

v3_develop
jos 10 years ago
parent
commit
8965e56a50
7 changed files with 23 additions and 25 deletions
  1. +2
    -2
      HISTORY.md
  2. +7
    -9
      dist/vis.js
  3. +1
    -1
      dist/vis.map
  4. +1
    -1
      dist/vis.min.js
  5. +1
    -1
      docs/network.html
  6. +4
    -2
      examples/network/02_random_nodes.html
  7. +7
    -9
      lib/network/Network.js

+ 2
- 2
HISTORY.md View File

@ -30,10 +30,10 @@ http://visjs.org
- Fixed physics solving stopping when a support node was not moving.
- Implemented localization support.
- Implemented option `clickToUse`.
- Improved the `'stabilized'` event, it's now firing after every stabilization
with iteration count as parameter.
- Fixed page scroll event not being blocked when moving around in Network
using arrow keys.
- Fixed the `'stabilized'` event, it's now guaranteed to fire only once and
fire after the graph is fully stabilized.
- Fixed an initial rendering before the graph has been stabilized.
### Graph2D

+ 7
- 9
dist/vis.js View File

@ -15806,11 +15806,8 @@ return /******/ (function(modules) { // webpackBootstrap
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._doInSupportSector("_discreteStepNodes", false);
}
this._findCenter(this._getRange())
if (!this.stabilized) {
this.stabilizationIterations++;
}
this.stabilizationIterations++;
}
}
};
@ -15882,17 +15879,18 @@ return /******/ (function(modules) { // webpackBootstrap
else {
this._redraw();
if (!this.stabilized) {
if (this.stabilizationIterations > 0) {
// trigger the "stabilized" event.
// The event is triggered on the next tick, to prevent the case that
// it is fired while initializing the Network, in which case you would not
// be able to catch it
this.stabilized = true;
var me = this;
var params = {
iterations: me.stabilizationIterations
};
me.stabilizationIterations = 0;
setTimeout(function () {
me.emit("stabilized",{
iterations: me.stabilizationIterations
});
me.emit("stabilized", params);
}, 0);
}
}

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


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


+ 1
- 1
docs/network.html View File

@ -2556,7 +2556,7 @@ network.off('select', onSelect);
</tr>
<tr>
<td>stabilized</td>
<td>Fired once when the network has been stabilized the first time. This event can be used to trigger the .storePosition() function after stabilization. Fired with an object having the following properties:</td>
<td>Fired every time the network has been stabilized. This event can be used to trigger the .storePosition() 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>

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

@ -79,8 +79,7 @@
var options = {
edges: {
},
stabilize: false
}
};
network = new vis.Network(container, data, options);
@ -88,6 +87,9 @@
network.on('select', function(params) {
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes;
});
network.on('stabilized', function (params) {
console.log('stabilized after ' + params.iterations + ' iterations');
});
}
</script>
</head>

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

@ -1989,11 +1989,8 @@ Network.prototype._physicsTick = function() {
if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) {
this._doInSupportSector("_discreteStepNodes", false);
}
this._findCenter(this._getRange())
if (!this.stabilized) {
this.stabilizationIterations++;
}
this.stabilizationIterations++;
}
}
};
@ -2065,17 +2062,18 @@ Network.prototype.start = function() {
else {
this._redraw();
if (!this.stabilized) {
if (this.stabilizationIterations > 0) {
// trigger the "stabilized" event.
// The event is triggered on the next tick, to prevent the case that
// it is fired while initializing the Network, in which case you would not
// be able to catch it
this.stabilized = true;
var me = this;
var params = {
iterations: me.stabilizationIterations
};
me.stabilizationIterations = 0;
setTimeout(function () {
me.emit("stabilized",{
iterations: me.stabilizationIterations
});
me.emit("stabilized", params);
}, 0);
}
}

Loading…
Cancel
Save