1
0
Fork 0

Made the create vertex option of GraphViewer aware of the mouse location. Not yet tested, hence disabled at some point before actual node positioning

This commit is contained in:
Michael Hackstein 2013-11-28 00:49:51 +01:00
parent a79d9b5123
commit a495fb4157
1 changed files with 14 additions and 5 deletions

View File

@ -138,9 +138,17 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
},
getCursorPositionInSVG = function (ev) {
var pos = getCursorPosition(ev);
pos.x -= $('svg').offset().left;
pos.y -= $('svg').offset().top;
var pos = getCursorPosition(ev),
off = $('svg').offset();
// Hack for Firefox
/*
var off = {
left: 166,
top: 171
};
*/
pos.x -= off.left;
pos.y -= off.top;
return pos;
};
/* Archive
@ -178,7 +186,8 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
this.newNodeRebinds = function() {
var prefix = "control_event_new_node",
idprefix = prefix + "_",
createCallback = function(n) {
createCallback = function(ev) {
var pos = getCursorPositionInSVG(ev);
modalDialogHelper.createModalCreateDialog(
"Create New Node",
idprefix,
@ -187,7 +196,7 @@ function EventDispatcherControls(list, nodeShaper, edgeShaper, dispatcherConfig)
dispatcher.events.CREATENODE(data, function(node) {
$("#" + idprefix + "modal").modal('hide');
nodeShaper.reshapeNodes();
})();
}, pos.x, pos.y)();
}
);
};