Browse Source

Removed move callbacks

flowchartTest
Alex de Mulder 9 years ago
parent
commit
64b2c78e00
5 changed files with 11 additions and 43 deletions
  1. +6
    -24
      dist/vis.js
  2. +2
    -1
      lib/network/modules/NodesHandler.js
  3. +2
    -5
      lib/network/modules/PhysicsEngine.js
  4. +0
    -11
      lib/network/modules/components/Node.js
  5. +1
    -2
      lib/network/modules/components/nodes/util/NodeBase.js

+ 6
- 24
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 4.6.1-SNAPSHOT
* @date 2015-07-24
* @date 2015-07-27
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -27653,7 +27653,8 @@ return /******/ (function(modules) { // webpackBootstrap
var _this4 = this;
if (this.body.nodes[nodeId] !== undefined) {
this.body.nodes[nodeId].move(Number(x), Number(y));
this.body.nodes[nodeId].x = Number(x);
this.body.nodes[nodeId].y = Number(y);
setTimeout(function () {
_this4.body.emitter.emit("startSimulation");
}, 0);
@ -28142,19 +28143,6 @@ return /******/ (function(modules) { // webpackBootstrap
return this.shape.boundingBox.left < obj.right && this.shape.boundingBox.right > obj.left && this.shape.boundingBox.top < obj.bottom && this.shape.boundingBox.bottom > obj.top;
}
/**
* move the node to a new position.
* @param x
* @param y
*/
}, {
key: 'move',
value: function move(x, y) {
this.x = x;
this.y = y;
this.shape.move(x, y);
}
/**
* clean all required things on delete.
* @returns {*}
@ -28734,10 +28722,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
// possible to overload in the shapes.
}, {
key: 'move',
value: function move(x, y) {}
// possible cleanup for use in shapes
}, {
key: 'cleanup',
value: function cleanup() {}
@ -33051,8 +33036,6 @@ return /******/ (function(modules) { // webpackBootstrap
var timestep = this.options.timestep;
var forces = this.physicsBody.forces;
var velocities = this.physicsBody.velocities;
var x = node.x;
var y = node.y;
// store the state so we can revert
this.previousStates[nodeId] = { x: node.x, y: node.y, vx: velocities[nodeId].x, vy: velocities[nodeId].y };
@ -33062,7 +33045,7 @@ return /******/ (function(modules) { // webpackBootstrap
var ax = (forces[nodeId].x - dx) / node.options.mass; // acceleration
velocities[nodeId].x += ax * timestep; // velocity
velocities[nodeId].x = Math.abs(velocities[nodeId].x) > maxVelocity ? velocities[nodeId].x > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].x;
x += velocities[nodeId].x * timestep; // position
node.x += velocities[nodeId].x * timestep; // position
} else {
forces[nodeId].x = 0;
velocities[nodeId].x = 0;
@ -33073,13 +33056,12 @@ return /******/ (function(modules) { // webpackBootstrap
var ay = (forces[nodeId].y - dy) / node.options.mass; // acceleration
velocities[nodeId].y += ay * timestep; // velocity
velocities[nodeId].y = Math.abs(velocities[nodeId].y) > maxVelocity ? velocities[nodeId].y > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].y;
y += velocities[nodeId].y * timestep; // position
node.y += velocities[nodeId].y * timestep; // position
} else {
forces[nodeId].y = 0;
velocities[nodeId].y = 0;
}
node.move(x, y);
var totalVelocity = Math.sqrt(Math.pow(velocities[nodeId].x, 2) + Math.pow(velocities[nodeId].y, 2));
return totalVelocity;
}

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

@ -434,7 +434,8 @@ class NodesHandler {
*/
moveNode(nodeId, x, y) {
if (this.body.nodes[nodeId] !== undefined) {
this.body.nodes[nodeId].move(Number(x), Number(y));
this.body.nodes[nodeId].x = Number(x);
this.body.nodes[nodeId].y = Number(y);
setTimeout(() => {this.body.emitter.emit("startSimulation")},0);
}
else {

+ 2
- 5
lib/network/modules/PhysicsEngine.js View File

@ -403,8 +403,6 @@ class PhysicsEngine {
let timestep = this.options.timestep;
let forces = this.physicsBody.forces;
let velocities = this.physicsBody.velocities;
let x = node.x;
let y = node.y;
// store the state so we can revert
this.previousStates[nodeId] = {x:node.x, y:node.y, vx:velocities[nodeId].x, vy:velocities[nodeId].y};
@ -414,7 +412,7 @@ class PhysicsEngine {
let ax = (forces[nodeId].x - dx) / node.options.mass; // acceleration
velocities[nodeId].x += ax * timestep; // velocity
velocities[nodeId].x = (Math.abs(velocities[nodeId].x) > maxVelocity) ? ((velocities[nodeId].x > 0) ? maxVelocity : -maxVelocity) : velocities[nodeId].x;
x += velocities[nodeId].x * timestep; // position
node.x += velocities[nodeId].x * timestep; // position
}
else {
forces[nodeId].x = 0;
@ -426,14 +424,13 @@ class PhysicsEngine {
let ay = (forces[nodeId].y - dy) / node.options.mass; // acceleration
velocities[nodeId].y += ay * timestep; // velocity
velocities[nodeId].y = (Math.abs(velocities[nodeId].y) > maxVelocity) ? ((velocities[nodeId].y > 0) ? maxVelocity : -maxVelocity) : velocities[nodeId].y;
y += velocities[nodeId].y * timestep; // position
node.y += velocities[nodeId].y * timestep; // position
}
else {
forces[nodeId].y = 0;
velocities[nodeId].y = 0;
}
node.move(x,y);
let totalVelocity = Math.sqrt(Math.pow(velocities[nodeId].x,2) + Math.pow(velocities[nodeId].y,2));
return totalVelocity;
}

+ 0
- 11
lib/network/modules/components/Node.js View File

@ -439,17 +439,6 @@ class Node {
);
}
/**
* move the node to a new position.
* @param x
* @param y
*/
move(x,y) {
this.x = x;
this.y = y;
this.shape.move(x,y)
}
/**
* clean all required things on delete.
* @returns {*}

+ 1
- 2
lib/network/modules/components/nodes/util/NodeBase.js View File

@ -68,8 +68,7 @@ class NodeBase {
}
}
// possible to overload in the shapes.
move(x,y) {}
// possible cleanup for use in shapes
cleanup() {}
}

Loading…
Cancel
Save