Basic double click handler

This commit is contained in:
Dennis Hotson 2013-03-14 22:26:28 +11:00
parent 4c0a9e3e28
commit 3df408fcc1
2 changed files with 15 additions and 3 deletions

View File

@ -6,7 +6,10 @@
<script>
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 jessica = graph.newNode({label: 'Jessica'});
var timothy = graph.newNode({label: 'Timothy'});

View File

@ -77,8 +77,6 @@ jQuery.fn.springy = function(params) {
var dragged = null;
jQuery(canvas).mousedown(function(e) {
jQuery('.actions').hide();
var pos = jQuery(this).offset();
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});
selected = nearest = dragged = layout.nearest(p);
@ -94,6 +92,17 @@ jQuery.fn.springy = function(params) {
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) {
var pos = jQuery(this).offset();
var p = fromScreen({x: e.pageX - pos.left, y: e.pageY - pos.top});