Merge remote branch 'lowerkey/master'

* lowerkey/master:
  Removed not yet implemented at the bottom of readme
  Using nodeSelected parameter.
  Added nodeSelected parameter, I think.
  Update README.mkdn
This commit is contained in:
Dennis Hotson 2012-10-21 20:08:57 +11:00
commit 87c46bee56
3 changed files with 15 additions and 1 deletions

View File

@ -93,3 +93,9 @@ Acknowledgements
Thanks to [Lachlan Donald](http://github.com/lox) for his helpful suggestions and
feedback.
Additions
----
This forked version adds a callback (called `nodeSelected` in the jquery
initializer. This callback is passed the node object.

View File

@ -30,7 +30,10 @@ graph.newEdge(bianca, monty, {color: '#EB6841'});
jQuery(function(){
var springy = jQuery('#springydemo').springy({
graph: graph
graph: graph,
nodeSelected: function(node){
console.log('Node selected: ' + JSON.stringify(node.data));
}
});
});
</script>

View File

@ -31,6 +31,8 @@ jQuery.fn.springy = function(params) {
var stiffness = params.stiffness || 400.0;
var repulsion = params.repulsion || 400.0;
var damping = params.damping || 0.5;
var nodeSelected = params.nodeSelected || null;
var canvas = this[0];
var ctx = canvas.getContext("2d");
@ -86,6 +88,9 @@ jQuery.fn.springy = function(params) {
// Part of the same bug mentioned later. Store the previous mass
// before upscaling it for dragging.
dragged.point.m = 10000.0;
// Call the nodeSelected code passed during initialization
nodeSelected(selected.node);
}
renderer.start();