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:
commit
87c46bee56
|
@ -93,3 +93,9 @@ Acknowledgements
|
||||||
|
|
||||||
Thanks to [Lachlan Donald](http://github.com/lox) for his helpful suggestions and
|
Thanks to [Lachlan Donald](http://github.com/lox) for his helpful suggestions and
|
||||||
feedback.
|
feedback.
|
||||||
|
|
||||||
|
Additions
|
||||||
|
----
|
||||||
|
|
||||||
|
This forked version adds a callback (called `nodeSelected` in the jquery
|
||||||
|
initializer. This callback is passed the node object.
|
|
@ -30,7 +30,10 @@ graph.newEdge(bianca, monty, {color: '#EB6841'});
|
||||||
|
|
||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
var springy = jQuery('#springydemo').springy({
|
var springy = jQuery('#springydemo').springy({
|
||||||
graph: graph
|
graph: graph,
|
||||||
|
nodeSelected: function(node){
|
||||||
|
console.log('Node selected: ' + JSON.stringify(node.data));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -32,6 +32,8 @@ jQuery.fn.springy = function(params) {
|
||||||
var repulsion = params.repulsion || 400.0;
|
var repulsion = params.repulsion || 400.0;
|
||||||
var damping = params.damping || 0.5;
|
var damping = params.damping || 0.5;
|
||||||
|
|
||||||
|
var nodeSelected = params.nodeSelected || null;
|
||||||
|
|
||||||
var canvas = this[0];
|
var canvas = this[0];
|
||||||
var ctx = canvas.getContext("2d");
|
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
|
// Part of the same bug mentioned later. Store the previous mass
|
||||||
// before upscaling it for dragging.
|
// before upscaling it for dragging.
|
||||||
dragged.point.m = 10000.0;
|
dragged.point.m = 10000.0;
|
||||||
|
|
||||||
|
// Call the nodeSelected code passed during initialization
|
||||||
|
nodeSelected(selected.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.start();
|
renderer.start();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user