Only call nodeSelected callback if it has been defined

This commit is contained in:
Dennis Hotson 2012-10-21 20:14:16 +11:00
parent 87c46bee56
commit fd1cd6ba49
2 changed files with 4 additions and 10 deletions

View File

@ -93,9 +93,3 @@ 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

@ -31,7 +31,6 @@ 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];
@ -88,9 +87,10 @@ 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);
if (nodeSelected) {
nodeSelected(selected.node);
}
}
renderer.start();