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

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

@ -39,15 +39,31 @@ class Canvas {
setOptions(options) { setOptions(options) {
if (options !== undefined) { 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 the HTML
*/ */
create() {
_create() {
// remove all elements from the container element. // remove all elements from the container element.
while (this.body.container.hasChildNodes()) { while (this.body.container.hasChildNodes()) {
this.body.container.removeChild(this.body.container.firstChild); this.body.container.removeChild(this.body.container.firstChild);
@ -137,6 +153,9 @@ class Canvas {
* or '30%') * or '30%')
*/ */
setSize(width = this.options.width, height = this.options.height) { setSize(width = this.options.width, height = this.options.height) {
width = this._prepareValue(width);
height= this._prepareValue(height);
let emitEvent = false; let emitEvent = false;
let oldWidth = this.frame.canvas.width; let oldWidth = this.frame.canvas.width;
let oldHeight = this.frame.canvas.height; 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.body.emitter.on("_startRendering", () => {
this.renderRequests += 1; this.renderRequests += 1;
this.renderingActive = true; this.renderingActive = true;
this.startRendering();
this._startRendering();
}); });
this.body.emitter.on("_stopRendering", () => { this.body.emitter.on("_stopRendering", () => {
this.renderRequests -= 1; this.renderRequests -= 1;
@ -59,14 +59,14 @@ class CanvasRenderer {
} }
} }
startRendering() {
_startRendering() {
if (this.renderingActive === true) { if (this.renderingActive === true) {
if (!this.renderTimer) { if (!this.renderTimer) {
if (this.requiresTimeout === true) { 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 { 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 // reset the renderTimer so a new scheduled animation step can be set
this.renderTimer = undefined; this.renderTimer = undefined;
if (this.requiresTimeout === true) { if (this.requiresTimeout === true) {
// this schedules a new simulation step // this schedules a new simulation step
this.startRendering();
this._startRendering();
} }
this._redraw(); this._redraw();
if (this.requiresTimeout === false) { if (this.requiresTimeout === false) {
// this schedules a new simulation step // 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 = { this.defaultOptions = {
borderWidth: 1, borderWidth: 1,
borderWidthSelected: undefined, borderWidthSelected: undefined,
brokenImage:undefined,
color: { color: {
border: '#2B7CE9', border: '#2B7CE9',
background: '#97C2FC', background: '#97C2FC',
@ -85,6 +86,7 @@ class NodesHandler {
}, },
shape: 'ellipse', shape: 'ellipse',
size: 25, size: 25,
title: undefined,
value: 1, value: 1,
x: undefined, x: undefined,
y: 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 { class BezierEdgeDynamic extends BezierEdgeBase {
constructor(options, body, labelModule) { constructor(options, body, labelModule) {
this.via = undefined;
super(options, body, labelModule); // --> this calls the setOptions below super(options, body, labelModule); // --> this calls the setOptions below
this.via = undefined;
} }
setOptions(options) { setOptions(options) {

Loading…
Cancel
Save