Updated springyui.js and demo
This commit is contained in:
parent
69cfbb490d
commit
f8e3ae7c62
|
@ -6,7 +6,10 @@
|
||||||
<script>
|
<script>
|
||||||
var graph = new Graph();
|
var graph = new Graph();
|
||||||
|
|
||||||
var dennis = graph.newNode({label: 'Dennis'});
|
var dennis = graph.newNode({
|
||||||
|
label: 'Dennis',
|
||||||
|
ondoubleclick: function() { console.log("Hello!"); }
|
||||||
|
});
|
||||||
var michael = graph.newNode({label: 'Michael'});
|
var michael = graph.newNode({label: 'Michael'});
|
||||||
var jessica = graph.newNode({label: 'Jessica'});
|
var jessica = graph.newNode({label: 'Jessica'});
|
||||||
var timothy = graph.newNode({label: 'Timothy'});
|
var timothy = graph.newNode({label: 'Timothy'});
|
||||||
|
|
13
springyui.js
13
springyui.js
|
@ -77,8 +77,6 @@ jQuery.fn.springy = function(params) {
|
||||||
var dragged = null;
|
var dragged = null;
|
||||||
|
|
||||||
jQuery(canvas).mousedown(function(e) {
|
jQuery(canvas).mousedown(function(e) {
|
||||||
jQuery('.actions').hide();
|
|
||||||
|
|
||||||
var pos = jQuery(this).offset();
|
var pos = jQuery(this).offset();
|
||||||
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
|
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
|
||||||
selected = nearest = dragged = layout.nearest(p);
|
selected = nearest = dragged = layout.nearest(p);
|
||||||
|
@ -94,6 +92,17 @@ jQuery.fn.springy = function(params) {
|
||||||
renderer.start();
|
renderer.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Basic double click handler
|
||||||
|
jQuery(canvas).dblclick(function(e) {
|
||||||
|
var pos = jQuery(this).offset();
|
||||||
|
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
|
||||||
|
selected = layout.nearest(p);
|
||||||
|
node = selected.node;
|
||||||
|
if (node && node.data && node.data.ondoubleclick) {
|
||||||
|
node.data.ondoubleclick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
jQuery(canvas).mousemove(function(e) {
|
jQuery(canvas).mousemove(function(e) {
|
||||||
var pos = jQuery(this).offset();
|
var pos = jQuery(this).offset();
|
||||||
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
|
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user