Browse Source

minor changes, adhere to ES6 in bezier edge dynamic

flowchartTest
Alex de Mulder 9 years ago
parent
commit
517263a27e
6 changed files with 1490 additions and 4502 deletions
  1. +1458
    -4490
      dist/vis.js
  2. +1
    -2
      lib/network/Network.js
  3. +21
    -2
      lib/network/modules/Canvas.js
  4. +7
    -7
      lib/network/modules/CanvasRenderer.js
  5. +2
    -0
      lib/network/modules/NodesHandler.js
  6. +1
    -1
      lib/network/modules/components/edges/BezierEdgeDynamic.js

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


+ 1
- 2
lib/network/Network.js View File

@ -111,7 +111,7 @@ function Network (container, data, options) {
this.configurationSystem = new ConfigurationSystem(this);
// create the DOM elements
this.canvas.create();
this.canvas._create();
// apply options
this.setOptions(options);
@ -125,7 +125,6 @@ function Network (container, data, options) {
Emitter(Network.prototype);
/**
* Set options
* @param {Object} options

+ 21
- 2
lib/network/modules/Canvas.js View File

@ -39,15 +39,31 @@ class Canvas {
setOptions(options) {
if (options !== undefined) {
util.deepExtend(this.options, options);
if (options.width !== undefined) {this.options.width = this._prepareValue(options.width );}
if (options.height!== undefined) {this.options.height= this._prepareValue(options.height);}
}
}
_prepareValue(value) {
if (typeof value === 'number') {
return value + 'px';
}
else if (typeof value === 'string') {
if (value.indexOf('%') !== -1 || value.indexOf('px') !== -1) {
return value;
}
else if (value.indexOf('%') === -1) {
return value + 'px';
}
}
throw new Error('Could not use the value supplie for width or height:' + value);
}
/**
* Create the HTML
*/
create() {
_create() {
// remove all elements from the container element.
while (this.body.container.hasChildNodes()) {
this.body.container.removeChild(this.body.container.firstChild);
@ -137,6 +153,9 @@ class Canvas {
* or '30%')
*/
setSize(width = this.options.width, height = this.options.height) {
width = this._prepareValue(width);
height= this._prepareValue(height);
let emitEvent = false;
let oldWidth = this.frame.canvas.width;
let oldHeight = this.frame.canvas.height;

+ 7
- 7
lib/network/modules/CanvasRenderer.js View File

@ -36,7 +36,7 @@ class CanvasRenderer {
this.body.emitter.on("_startRendering", () => {
this.renderRequests += 1;
this.renderingActive = true;
this.startRendering();
this._startRendering();
});
this.body.emitter.on("_stopRendering", () => {
this.renderRequests -= 1;
@ -59,14 +59,14 @@ class CanvasRenderer {
}
}
startRendering() {
_startRendering() {
if (this.renderingActive === true) {
if (!this.renderTimer) {
if (this.requiresTimeout === true) {
this.renderTimer = window.setTimeout(this.renderStep.bind(this), this.simulationInterval); // wait this.renderTimeStep milliseconds and perform the animation step function
this.renderTimer = window.setTimeout(this._renderStep.bind(this), this.simulationInterval); // wait this.renderTimeStep milliseconds and perform the animation step function
}
else {
this.renderTimer = window.requestAnimationFrame(this.renderStep.bind(this)); // wait this.renderTimeStep milliseconds and perform the animation step function
this.renderTimer = window.requestAnimationFrame(this._renderStep.bind(this)); // wait this.renderTimeStep milliseconds and perform the animation step function
}
}
}
@ -75,20 +75,20 @@ class CanvasRenderer {
}
}
renderStep() {
_renderStep() {
// reset the renderTimer so a new scheduled animation step can be set
this.renderTimer = undefined;
if (this.requiresTimeout === true) {
// this schedules a new simulation step
this.startRendering();
this._startRendering();
}
this._redraw();
if (this.requiresTimeout === false) {
// this schedules a new simulation step
this.startRendering();
this._startRendering();
}
}

+ 2
- 0
lib/network/modules/NodesHandler.js View File

@ -25,6 +25,7 @@ class NodesHandler {
this.defaultOptions = {
borderWidth: 1,
borderWidthSelected: undefined,
brokenImage:undefined,
color: {
border: '#2B7CE9',
background: '#97C2FC',
@ -85,6 +86,7 @@ class NodesHandler {
},
shape: 'ellipse',
size: 25,
title: undefined,
value: 1,
x: undefined,
y: undefined

+ 1
- 1
lib/network/modules/components/edges/BezierEdgeDynamic.js View File

@ -2,8 +2,8 @@ import BezierEdgeBase from './util/BezierEdgeBase'
class BezierEdgeDynamic extends BezierEdgeBase {
constructor(options, body, labelModule) {
this.via = undefined;
super(options, body, labelModule); // --> this calls the setOptions below
this.via = undefined;
}
setOptions(options) {

Loading…
Cancel
Save