Browse Source

cleaned up the setSize function

v3_develop
Alex de Mulder 10 years ago
parent
commit
6891b4bf2a
6 changed files with 7409 additions and 7564 deletions
  1. +1
    -1
      HISTORY.md
  2. +7374
    -7550
      dist/vis.js
  3. +1
    -1
      dist/vis.min.css
  4. +1
    -1
      docs/network.html
  5. +2
    -4
      examples/network/02_random_nodes.html
  6. +30
    -7
      lib/network/Network.js

+ 1
- 1
HISTORY.md View File

@ -47,7 +47,7 @@ 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
- 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.

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


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


+ 1
- 1
docs/network.html View File

@ -2554,7 +2554,7 @@ network.off('select', onSelect);
</tr>
<tr>
<td>resize</td>
<td>Fired when the size of the canvas has been updated (not neccecarily changed) by the setSize() function or by the setOptions() function.</td>
<td>Fired when the size of the canvas has been resized, either by a redraw call when the container div has changed in size, a setSize() call with new values or a setOptions() with new width and/or height values.</td>
<td>
<ul>
<li><code>width</code>: the new width of the canvas</li>

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

@ -8,8 +8,6 @@
font: 10pt sans;
}
#mynetwork {
width: 600px;
height: 600px;
border: 1px solid lightgray;
}
</style>
@ -78,8 +76,6 @@
};
var options = {
edges: {
}
};
network = new vis.Network(container, data, options);
@ -90,7 +86,9 @@
network.on('stabilized', function (params) {
document.getElementById('stabilization').innerHTML = 'Stabilization took ' + params.iterations + ' iterations.';
});
}
</script>
</head>

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

@ -1277,16 +1277,39 @@ Network.prototype._checkHidePopup = function (pointer) {
* or '30%')
*/
Network.prototype.setSize = function(width, height) {
this.frame.style.width = width;
this.frame.style.height = height;
var emitEvent = false;
if (width != this.constants.width || height != this.constants.height || this.frame.style.width != width || this.frame.style.height != height) {
this.frame.style.width = width;
this.frame.style.height = height;
this.frame.canvas.style.width = '100%';
this.frame.canvas.style.height = '100%';
this.frame.canvas.style.width = '100%';
this.frame.canvas.style.height = '100%';
this.frame.canvas.width = this.frame.canvas.clientWidth;
this.frame.canvas.height = this.frame.canvas.clientHeight;
this.frame.canvas.width = this.frame.canvas.clientWidth;
this.frame.canvas.height = this.frame.canvas.clientHeight;
this.emit('resize', {width:this.frame.canvas.width,height:this.frame.canvas.height});
this.constants.width = width;
this.constants.height = height;
emitEvent = true;
}
else {
// this would adapt the width of the canvas to the width from 100% if and only if
// there is a change.
if (this.frame.canvas.width != this.frame.canvas.clientWidth) {
this.frame.canvas.width = this.frame.canvas.clientWidth;
emitEvent = true;
}
if (this.frame.canvas.height != this.frame.canvas.clientHeight) {
this.frame.canvas.height = this.frame.canvas.clientHeight;
emitEvent = true;
}
}
if (emitEvent == true) {
this.emit('resize', {width:this.frame.canvas.width,height:this.frame.canvas.height});
}
};
/**

Loading…
Cancel
Save