Skip to content

Commit

Permalink
Do not store cytoscape instance in plugin global variable. (#8)
Browse files Browse the repository at this point in the history
Fix issue with multiple instances of cytoscape.
  • Loading branch information
Artem Kozlov authored and mrsfy committed Jul 24, 2016
1 parent 3380914 commit 6b37b09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions cytoscape-expand-collapse.js

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
var elementUtilities = require('./elementUtilities');
$.fn.cytoscapeExpandCollapse = require("./cueUtilities");


var cy;
var options = {
layoutBy: null, // for rearrange after expand/collapse. It's just layout options or whole layout function. Choose your side!
fisheye: true, // whether to perform fisheye view after expand/collapse you can specify a function too
Expand Down Expand Up @@ -55,7 +53,7 @@

// cy.expandCollapse()
cytoscape("core", "expandCollapse", function (opts) {
cy = this;
var cy = this;
options = setOptions(opts);

// All parent nodes are expanded on load
Expand Down Expand Up @@ -94,7 +92,7 @@
var tempOptions = setOptions(opts);
evalOptions(tempOptions);

return expandCollapseUtilities(cy).collapseGivenNodes(eles, tempOptions);
return expandCollapseUtilities(this.cy()).collapseGivenNodes(eles, tempOptions);
});

// eles.collapseAll(options)
Expand All @@ -112,7 +110,7 @@
var tempOptions = setOptions(opts);
evalOptions(tempOptions);

return expandCollapseUtilities(cy).expandGivenNodes(eles, tempOptions);
return expandCollapseUtilities(this.cy()).expandGivenNodes(eles, tempOptions);
});

// eles.expandAll(options)
Expand All @@ -121,7 +119,7 @@
var tempOptions = setOptions(opts);
evalOptions(tempOptions);

return expandCollapseUtilities(cy).expandAllNodes(eles, tempOptions);
return expandCollapseUtilities(this.cy()).expandAllNodes(eles, tempOptions);
});


Expand Down

0 comments on commit 6b37b09

Please sign in to comment.