Skip to content

Commit

Permalink
Multi node resize disabled #6
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsfy committed Oct 2, 2016
1 parent 123cc74 commit fd77cea
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
55 changes: 48 additions & 7 deletions cytoscape-node-resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@
};

var restoreGrapples = function () {
if (cy.nodes(":selected").size() != 1)
return;

cy.nodes(":selected").each(function (i, node) {
drawGrapples(node);
});
Expand All @@ -599,15 +602,53 @@
clearDrawing();
restoreGrapples();
};
var redraw = debounce(redrawNow, 15);

cy.on("unselect", "node", redraw);
cy.on("position", "node", redraw);
cy.on("zoom", redraw);
cy.on("pan", redraw);
cy.on("style", "node", redraw);
var selectParticularNode = function(e) {
var node = this;
if (cy.nodes(":selected").size() != 1)
redrawNow();
else
drawGrapples(node);

};

var unBindEvents = function() {
cy.off("unselect", "node", redraw);
cy.off("position", "node", redraw);
cy.off("zoom", redraw);
//cy.off("pan", redraw);
//cy.off("style", "node", redraw);
cy.off("select", "node", selectParticularNode);
};

var redraw = debounce(redrawNow, 150);
var bindEvents = function() {
cy.on("unselect", "node", redrawNow);
cy.on("position", "node", redrawNow);
cy.on("zoom", redrawNow);
cy.on("pan", redrawNow);
//cy.on("style", "node", redraw);
cy.on("select", "node", selectParticularNode);
};
bindEvents();

var clearOnDrag = function() {
clearDrawing();
cy.off("drag", clearOnDrag);
}

/*
cy.on("grab", function() {
unBindEvents();
clearDrawing();
cy.on("drag", clearOnDrag);
});
cy.on("free", "node", function() {
redrawNow();
bindEvents();
cy.on("select", "node", redraw);
});*/

if (cy.undoRedo && options.undoable) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cytoscape-node-resize",
"version": "1.0.3",
"version": "1.0.5",
"description": "",
"main": "cytoscape-node-resize.js",
"spm": {
Expand Down

0 comments on commit fd77cea

Please sign in to comment.