Updated to latest springy version
This commit is contained in:
parent
8b12e8b038
commit
69cfbb490d
|
@ -29,7 +29,7 @@ graph.newEdge(dennis, bianca, {color: '#CC333F'});
|
|||
graph.newEdge(bianca, monty, {color: '#EB6841'});
|
||||
|
||||
jQuery(function(){
|
||||
var springy = jQuery('#springydemo').springy({
|
||||
var springy = window.springy = jQuery('#springydemo').springy({
|
||||
graph: graph,
|
||||
nodeSelected: function(node){
|
||||
console.log('Node selected: ' + JSON.stringify(node.data));
|
||||
|
|
15
springy.js
15
springy.js
|
@ -168,6 +168,10 @@ of nodes and edges:
|
|||
}
|
||||
|
||||
**/
|
||||
// parse if a string is passed (EC5+ browsers)
|
||||
if (typeof json == 'string' || json instanceof String) {
|
||||
json = JSON.parse( json );
|
||||
}
|
||||
|
||||
if ('nodes' in json || 'edges' in json) {
|
||||
this.addNodes.apply(this, json['nodes']);
|
||||
|
@ -464,6 +468,7 @@ Layout.ForceDirected.prototype.start = function(render, done) {
|
|||
|
||||
if (this._started) return;
|
||||
this._started = true;
|
||||
this._stop = false;
|
||||
|
||||
Layout.requestAnimationFrame(function step() {
|
||||
t.applyCoulombsLaw();
|
||||
|
@ -477,7 +482,7 @@ Layout.ForceDirected.prototype.start = function(render, done) {
|
|||
}
|
||||
|
||||
// stop simulation when energy of the system goes below a threshold
|
||||
if (t.totalEnergy() < 0.01) {
|
||||
if (t._stop || t.totalEnergy() < 0.01) {
|
||||
t._started = false;
|
||||
if (done !== undefined) { done(); }
|
||||
} else {
|
||||
|
@ -486,6 +491,10 @@ Layout.ForceDirected.prototype.start = function(render, done) {
|
|||
});
|
||||
};
|
||||
|
||||
Layout.ForceDirected.prototype.stop = function() {
|
||||
this._stop = true;
|
||||
}
|
||||
|
||||
// Find the nearest point to a particular position
|
||||
Layout.ForceDirected.prototype.nearest = function(pos) {
|
||||
var min = {node: null, point: null, distance: null};
|
||||
|
@ -624,6 +633,10 @@ Renderer.prototype.start = function() {
|
|||
});
|
||||
};
|
||||
|
||||
Renderer.prototype.stop = function() {
|
||||
this.layout.stop();
|
||||
};
|
||||
|
||||
// Array.forEach implementation for IE support..
|
||||
//https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
|
||||
if ( !Array.prototype.forEach ) {
|
||||
|
|
|
@ -131,7 +131,7 @@ jQuery.fn.springy = function(params) {
|
|||
return 20;
|
||||
};
|
||||
|
||||
var renderer = new Renderer(layout,
|
||||
var renderer = this.renderer = new Renderer(layout,
|
||||
function clear() {
|
||||
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user