Only call nodeSelected callback if it has been defined
This commit is contained in:
parent
87c46bee56
commit
fd1cd6ba49
|
@ -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.
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user