Browse Source

experiment

css_transitions
Alex de Mulder 10 years ago
parent
commit
69dfd22d58
3 changed files with 68 additions and 9 deletions
  1. +35
    -5
      dist/vis.js
  2. +26
    -2
      src/graph/Graph.js
  3. +7
    -2
      src/graph/Node.js

+ 35
- 5
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library.
*
* @version 0.8.0-SNAPSHOT
* @date 2014-03-21
* @date 2014-03-24
*
* @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -9477,6 +9477,7 @@ function Node(properties, imagelist, grouplist, constants) {
this.minForce = constants.minForce;
this.damping = constants.physics.damping;
this.mass = 1; // kg
this.fixedData = {x:null,y:null};
this.setProperties(properties, constants);
@ -9560,8 +9561,6 @@ Node.prototype.setProperties = function(properties, constants) {
// physics
if (properties.internalMultiplier !== undefined) {this.internalMultiplier = properties.internalMultiplier;}
if (properties.damping !== undefined) {this.dampingBase = properties.damping;}
if (properties.mass !== undefined) {this.mass = properties.mass;}
// navigation controls properties
@ -9832,6 +9831,9 @@ Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
this.vx = (Math.abs(this.vx) > maxVelocity) ? ((this.vx > 0) ? maxVelocity : -maxVelocity) : this.vx;
this.x += this.vx * interval; // position
}
else {
this.fx = 0;
}
if (!this.yFixed) {
var dy = this.damping * this.vy; // damping force
@ -9840,6 +9842,9 @@ Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
this.vy = (Math.abs(this.vy) > maxVelocity) ? ((this.vy > 0) ? maxVelocity : -maxVelocity) : this.vy;
this.y += this.vy * interval; // position
}
else {
this.fy = 0;
}
};
/**
@ -17722,11 +17727,36 @@ Graph.prototype._stabilize = function() {
this._physicsTick();
count++;
}
this.zoomExtent(false,true);
this.emit("stabilized",{iterations:count});
};
Graph.prototype.freezeDefinedNodes = function() {
var nodes = this.nodes;
for (var id in nodes) {
if (nodes.hasOwnProperty(id)) {
if (nodes[id].x != null && nodes[id].y != null) {
nodes[id].fixedData.x = nodes[id].xFixed;
nodes[id].fixedData.y = nodes[id].yFixed;
nodes[id].xFixed = true;
nodes[id].yFixed = true;
}
}
}
};
Graph.prototype.restoreFrozenNodes = function() {
var nodes = this.nodes;
for (var id in nodes) {
if (nodes.hasOwnProperty(id)) {
if (nodes[id].fixedData.x != null) {
nodes[id].xFixed = nodes[id].fixedData.x;
nodes[id].yFixed = nodes[id].fixedData.y;
}
}
}
};
/**
@ -17785,10 +17815,10 @@ Graph.prototype._physicsTick = function() {
if (!this.freezeSimulation) {
if (this.moving) {
this._doInAllActiveSectors("_initializeForceCalculation");
this._doInAllActiveSectors("_discreteStepNodes");
if (this.constants.smoothCurves) {
this._doInSupportSector("_discreteStepNodes");
}
this._doInAllActiveSectors("_discreteStepNodes");
this._findCenter(this._getRange())
}
}

+ 26
- 2
src/graph/Graph.js View File

@ -1722,12 +1722,36 @@ Graph.prototype._stabilize = function() {
this._physicsTick();
count++;
}
this.zoomExtent(false,true);
this.emit("stabilized",{iterations:count});
};
Graph.prototype.freezeDefinedNodes = function() {
var nodes = this.nodes;
for (var id in nodes) {
if (nodes.hasOwnProperty(id)) {
if (nodes[id].x != null && nodes[id].y != null) {
nodes[id].fixedData.x = nodes[id].xFixed;
nodes[id].fixedData.y = nodes[id].yFixed;
nodes[id].xFixed = true;
nodes[id].yFixed = true;
}
}
}
};
Graph.prototype.restoreFrozenNodes = function() {
var nodes = this.nodes;
for (var id in nodes) {
if (nodes.hasOwnProperty(id)) {
if (nodes[id].fixedData.x != null) {
nodes[id].xFixed = nodes[id].fixedData.x;
nodes[id].yFixed = nodes[id].fixedData.y;
}
}
}
};
/**
@ -1786,10 +1810,10 @@ Graph.prototype._physicsTick = function() {
if (!this.freezeSimulation) {
if (this.moving) {
this._doInAllActiveSectors("_initializeForceCalculation");
this._doInAllActiveSectors("_discreteStepNodes");
if (this.constants.smoothCurves) {
this._doInSupportSector("_discreteStepNodes");
}
this._doInAllActiveSectors("_discreteStepNodes");
this._findCenter(this._getRange())
}
}

+ 7
- 2
src/graph/Node.js View File

@ -66,6 +66,7 @@ function Node(properties, imagelist, grouplist, constants) {
this.minForce = constants.minForce;
this.damping = constants.physics.damping;
this.mass = 1; // kg
this.fixedData = {x:null,y:null};
this.setProperties(properties, constants);
@ -149,8 +150,6 @@ Node.prototype.setProperties = function(properties, constants) {
// physics
if (properties.internalMultiplier !== undefined) {this.internalMultiplier = properties.internalMultiplier;}
if (properties.damping !== undefined) {this.dampingBase = properties.damping;}
if (properties.mass !== undefined) {this.mass = properties.mass;}
// navigation controls properties
@ -421,6 +420,9 @@ Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
this.vx = (Math.abs(this.vx) > maxVelocity) ? ((this.vx > 0) ? maxVelocity : -maxVelocity) : this.vx;
this.x += this.vx * interval; // position
}
else {
this.fx = 0;
}
if (!this.yFixed) {
var dy = this.damping * this.vy; // damping force
@ -429,6 +431,9 @@ Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
this.vy = (Math.abs(this.vy) > maxVelocity) ? ((this.vy > 0) ? maxVelocity : -maxVelocity) : this.vy;
this.y += this.vy * interval; // position
}
else {
this.fy = 0;
}
};
/**

Loading…
Cancel
Save