diff --git a/cytoscape-expand-collapse.js b/cytoscape-expand-collapse.js
index 268aef3..67bc84e 100644
--- a/cytoscape-expand-collapse.js
+++ b/cytoscape-expand-collapse.js
@@ -30,8 +30,8 @@ module.exports = function (params) {
init: function () {
var self = this;
var opts = params;
- var $container = $(this);
- var cy;
+ var $container = this;
+ var cy = this.cytoscape('get');
var $canvas = $('');
$container.append($canvas);
@@ -314,6 +314,7 @@ module.exports = function (params) {
$container.data('cyexpandcollapse', data);
},
unbind: function () {
+ var cy = this.cytoscape('get');
cy.off('mouseover', 'node', eMouseOver)
.off('mouseout tapdragout', 'node', eMouseOut)
.off('position', 'node', ePosition)
@@ -336,6 +337,7 @@ module.exports = function (params) {
return $(this);
};
+
},{"./debounce":3}],3:[function(_dereq_,module,exports){
var debounce = (function () {
/**
@@ -1524,4 +1526,4 @@ module.exports = function (cy) {
},{}]},{},[6])(6)
});
-//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvYm91bmRpbmdCb3hVdGlsaXRpZXMuanMiLCJzcmMvY3VlVXRpbGl0aWVzLmpzIiwic3JjL2RlYm91bmNlLmpzIiwic3JjL2VsZW1lbnRVdGlsaXRpZXMuanMiLCJzcmMvZXhwYW5kQ29sbGFwc2VVdGlsaXRpZXMuanMiLCJzcmMvaW5kZXguanMiLCJzcmMvdW5kb1JlZG9VdGlsaXRpZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ25CQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FB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4gICAgICAgICRjYW52YXNcbiAgICAgICAgICAuYXR0cignaGVpZ2h0JywgJGNvbnRhaW5lci5oZWlnaHQoKSlcbiAgICAgICAgICAuYXR0cignd2lkdGgnLCAkY29udGFpbmVyLndpZHRoKCkpXG4gICAgICAgICAgLmNzcyh7XG4gICAgICAgICAgICAncG9zaXRpb24nOiAnYWJzb2x1dGUnLFxuICAgICAgICAgICAgJ3RvcCc6IDAsXG4gICAgICAgICAgICAnbGVmdCc6IDAsXG4gICAgICAgICAgICAnei1pbmRleCc6ICc5OTknXG4gICAgICAgICAgfSlcbiAgICAgICAgO1xuXG4gICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHZhciBjYW52YXNCYiA9ICRjYW52YXMub2Zmc2V0KCk7XG4gICAgICAgICAgdmFyIGNvbnRhaW5lckJiID0gJGNvbnRhaW5lci5vZmZzZXQoKTtcblxuICAgICAgICAgICRjYW52YXNcbiAgICAgICAgICAgIC5jc3Moe1xuICAgICAgICAgICAgICAndG9wJzogLShjYW52YXNCYi50b3AgLSBjb250YWluZXJCYi50b3ApLFxuICAgICAgICAgICAgICAnbGVmdCc6IC0oY2FudmFzQmIubGVmdCAtIGNvbnRhaW5lckJiLmxlZnQpXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIDtcblxuICAgICAgICAgIC8vIHJlZnJlc2ggdGhlIGN1ZXMgb24gY2FudmFzIHJlc2l6ZVxuICAgICAgICAgIGlmKGN5KXtcbiAgICAgICAgICAgIGNsZWFyRHJhd3ModHJ1ZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9LCAwKTtcblxuICAgICAgfSwgMjUwKTtcblxuICAgICAgZnVuY3Rpb24gc2l6ZUNhbnZhcygpIHtcbiAgICAgICAgX3NpemVDYW52YXMoKTtcbiAgICAgIH1cblxuICAgICAgc2l6ZUNhbnZhcygpO1xuXG4gICAgICAkKHdpbmRvdykuYmluZCgncmVzaXplJywgZnVuY3Rpb24gKCkge1xuICAg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G9zaXRpb24gPSB7fTtcblxuICAgICAgICB9KTtcblxuICAgICAgICBjeS5vbignbW91c2VvdXQgdGFwZHJhZ291dCcsICdub2RlJywgZU1vdXNlT3V0ID0gZnVuY3Rpb24gKGUpIHtcblxuICAgICAgICAgIGNsZWFyRHJhd3ModHJ1ZSk7XG5cbiAgICAgICAgfSk7XG5cbiAgICAgICAgY3kub24oJ3Bvc2l0aW9uJywgJ25vZGUnLCBlUG9zaXRpb24gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgdmFyIG5vZGUgPSB0aGlzO1xuXG4gICAgICAgICAgY2xlYXJEcmF3cyh0cnVlKTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgY3kub24oJ3JlbW92ZScsICdub2RlJywgZVJlbW92ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICB2YXIgbm9kZSA9IHRoaXM7XG4gICAgICAgICAgY2xlYXJOb2RlRHJhdyhub2RlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIFxuICAgICAgICBjeS5vbignYWRkJywgJ25vZGUnLCBlQWRkID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHZhciBub2RlID0gdGhpcztcbiAgICAgICAgICBkcmF3RXhwYW5kQ29sbGFwc2VDdWUobm9kZSk7XG4gICAgICAgIH0pO1xuICAgICAgICBcbiAgICAgICAgY3kub24oJ2ZyZWUnLCAnbm9kZScsIGVGcmVlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHZhciBub2RlID0gdGhpcztcbiAgICAgICAgICBcbiAgICAgICAgICBjbGVhckRyYXdzKHRydWUpO1xuICAgICAgICB9KTtcbiAgICAgICAgXG4gICAgICAgIHZhciB1cjtcbiAgICAgICAgY3kub24oJ3RhcCcsICdub2RlJywgZVRhcCA9IGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgIHZhciBub2RlID0gdGhpcztcblxuICAgICAgICAgIHZhciBleHBhbmRjb2xsYXBzZVJlbmRlcmVkU3RhcnRYID0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c2VSZW5kZXJlZEVuZFggKyBleHBhbmRjb2xsYXBzZVJlbmRlcmVkUmVjdFNpemUgKiBmYWN0b3JcbiAgICAgICAgICAgICYmIGN5UmVuZGVyZWRQb3NZID49IGV4cGFuZGNvbGxhcHNlUmVuZGVyZWRTdGFydFkgLSBleHBhbmRjb2xsYXBzZVJlbmRlcmVkUmVjdFNpemUgKiBmYWN0b3JcbiAgICAgICAgICAgICYmIGN5UmVuZGVyZWRQb3NZIDw9IGV4cGFuZGNvbGxhcHNlUmVuZGVyZWRFbmRZICsgZXhwYW5kY29sbGFwc2VSZW5kZXJlZFJlY3RTaXplICogZmFjdG9yKSB7XG4gICAgICAgICAgICBpZihvcHRzLnVuZG9hYmxlICYmICF1cilcbiAgICAgICAgICAgICAgdXIgPSBjeS51bmRvUmVkbyh7XG4gICAgICAgICAgICAgICAgZGVmYXVsdEFjdGlvbnM6IGZhbHNlXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYobm9kZS5pc0NvbGxhcHNpYmxlKCkpXG4gICAgICAgICAgICAgIGlmIChvcHRzLnVuZG9hYmxlKVxuICAgICAgICAgICAgICAgIHVyLmRvKFwiY29sbGFwc2VcIiwge1xuICAgICAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICAgICAgICBvcHRpb25zOiBvcHRzXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICBub2RlLmNvbGxhcHNlKG9wdHMpO1xuICAgICAgICAgICAgZWxzZSBpZihub2RlLmlzRXhwYW5kYWJsZSgpKVxuICAgICAgICAgICAgICBpZiAob3B0cy51bmRvYWJsZSlcbiAgICAgICAgICAgICAgICB1ci5kbyhcImV4cGFuZFwiLCB7XG4gICAgICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgICAgICAgIG9wdGlvbnM6IG9wdHNcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAg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1bWVudHM7XG4gICAgICBzdGFtcCA9IG5vdygpO1xuICAgICAgdGhpc0FyZyA9IHRoaXM7XG4gICAgICB0cmFpbGluZ0NhbGwgPSB0cmFpbGluZyAmJiAodGltZW91dElkIHx8ICFsZWFkaW5nKTtcblxuICAgICAgaWYgKG1heFdhaXQgPT09IGZhbHNlKSB7XG4gICAgICAgIHZhciBsZWFkaW5nQ2FsbCA9IGxlYWRpbmcgJiYgIXRpbWVvdXRJZDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICghbWF4VGltZW91dElkICYmICFsZWFkaW5nKSB7XG4gICAgICAgICAgbGFzdENhbGxlZCA9IHN0YW1wO1xuICAgICAgICB9XG4gICAgICAgIHZhciByZW1haW5pbmcgPSBtYXhXYWl0IC0gKHN0YW1wIC0gbGFzdENhbGxlZCksXG4gICAgICAgICAgICAgICAgaXNDYWxsZWQgPSByZW1haW5pbmcgPD0gMCB8fCByZW1haW5pbmcgPiBtYXhXYWl0O1xuXG4gICAgICAgIGlmIChpc0NhbGxlZCkge1xuICAgICAgICAgIGlmIChtYXhUaW1lb3V0SWQpIHtcbiAgICAgICAgICAgIG1heFRpbWVvdXRJZCA9IGNsZWFyVGltZW91dChtYXhUaW1lb3V0SWQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBsYXN0Q2FsbGVkID0gc3RhbXA7XG4gICAgICAgICAgcmVzdWx0ID0gZnVuYy5hcHBseSh0aGlzQXJnLCBhcmdzKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmICghbWF4VGltZW91dElkKSB7XG4gICAgICAgICAgbWF4VGltZW91dElkID0gc2V0VGltZW91dChtYXhEZWxheWVkLCByZW1haW5pbmcpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAoaXNDYWxsZWQgJiYgdGltZW91dElkKSB7XG4gICAgICAgIHRpbWVvdXRJZCA9IGNsZWFyVGltZW91dCh0aW1lb3V0SWQpO1xuICAgICAgfVxuICAgICAgZWxzZSBpZi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cbiAgICAgICAgICAgICd0b3AnOiAwLFxuICAgICAgICAgICAgJ2xlZnQnOiAwLFxuICAgICAgICAgICAgJ3otaW5kZXgnOiAnOTk5J1xuICAgICAgICAgIH0pXG4gICAgICAgIDtcblxuICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICB2YXIgY2FudmFzQmIgPSAkY2FudmFzLm9mZnNldCgpO1xuICAgICAgICAgIHZhciBjb250YWluZXJCYiA9ICRjb250YWluZXIub2Zmc2V0KCk7XG5cbiAgICAgICAgICAkY2FudmFzXG4gICAgICAgICAgICAuY3NzKHtcbiAgICAgICAgICAgICAgJ3RvcCc6IC0oY2FudmFzQmIudG9wIC0gY29udGFpbmVyQmIudG9wKSxcbiAgICAgICAgICAgICAgJ2xlZnQnOiAtKGNhbnZhc0JiLmxlZnQgLSBjb250YWluZXJCYi5sZWZ0KVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICA7XG5cbiAgICAgICAgICAvLyByZWZyZXNoIHRoZSBjdWVzIG9uIGNhbnZhcyByZXNpemVcbiAgICAgICAgICBpZihjeSl7XG4gICAgICAgICAgICBjbGVhckRyYXdzKHRydWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSwgMCk7XG5cbiAgICAgIH0sIDI1MCk7XG5cbiAgICAgIGZ1bmN0aW9uIHNpemVDYW52YXMoKSB7XG4gICAgICAgIF9zaXplQ2FudmFzKCk7XG4gICAgICB9XG5cbiAgICAgIHNpemVDYW52YXMoKTtcblxuICAgICAgJCh3aW5kb3cpLmJpbmQoJ3Jlc2l6ZScsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgc2l6ZUNhbnZhcygpO1xuICAgICAgfSk7XG5cbiAgICAgIHZhciBjdHggPSAkY2FudmFzWzBdLmdldENvbnRleHQoJzJkJyk7XG5cbiAgICAgIC8vIHdyaXRlIG9wdGlvbnMgdG8gZGF0YVxuICAgICAgdmFyIGRhdGEgPSAkY29udGFpbmVyLmRhdGEo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RZIC0gZXhwYW5kY29sbGFwc2VSZW5kZXJlZFJlY3RTaXplICogZmFjdG9yXG4gICAgICAgICAgICAmJiBjeVJlbmRlcmVkUG9zWSA8PSBleHBhbmRjb2xsYXBzZVJlbmRlcmVkRW5kWSArIGV4cGFuZGNvbGxhcHNlUmVuZGVyZWRSZWN0U2l6ZSAqIGZhY3Rvcikge1xuICAgICAgICAgICAgaWYob3B0cy51bmRvYWJsZSAmJiAhdXIpXG4gICAgICAgICAgICAgIHVyID0gY3kudW5kb1JlZG8oe1xuICAgICAgICAgICAgICAgIGRlZmF1bHRBY3Rpb25zOiBmYWxzZVxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmKG5vZGUuaXNDb2xsYXBzaWJsZSgpKVxuICAgICAgICAgICAgICBpZiAob3B0cy51bmRvYWJsZSlcbiAgICAgICAgICAgICAgICB1ci5kbyhcImNvbGxhcHNlXCIsIHtcbiAgICAgICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgICAgICAgb3B0aW9uczogb3B0c1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgbm9kZS5jb2xsYXBzZShvcHRzKTtcbiAgICAgICAgICAgIGVsc2UgaWYobm9kZS5pc0V4cGFuZGFibGUoKSlcbiAgICAgICAgICAgICAgaWYgKG9wdHMudW5kb2FibGUpXG4gICAgICAgICAgICAgICAgdXIuZG8oXCJleHBhbmRcIiwge1xuICAgICAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICAgICAgICBvcHRpb25zOiBvcHRzXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICBub2RlLmV4cGFuZChvcHRzKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfSk7XG5cbiAgICAgICRjb250YWluZXIuZGF0YSgnY3lleHBhbmRjb2xsYXBzZScsI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ICAgICB5MjogYm90dG9tUmlnaHRQb3NpdGlvbi55XG4gICAgICAgIH07XG5cbiAgICAgICAgdmFyIG5vZGVCQiA9IHtcbiAgICAgICAgICB4MTogbm9kZS5wb3NpdGlvbigneCcpIC0gbm9kZS5kYXRhKCdzaXplLWJlZm9yZS1jb2xsYXBzZScpLncgLyAyIC0gcGFkZGluZyxcbiAgICAgICAgICB4Mjogbm9kZS5wb3NpdGlvbigneCcpICsgbm9kZS5kYXRhKCdzaXplLWJlZm9yZS1jb2xsYXBzZScpLncgLyAyICsgcGFkZGluZyxcbiAgICAgICAgICB5MTogbm9kZS5wb3NpdGlvbigneScpIC0gbm9kZS5kYXRhKCdzaXplLWJlZm9yZS1jb2xsYXBzZScpLmggLyAyIC0gcGFkZGluZyxcbiAgICAgICAgICB5Mjogbm9kZS5wb3NpdGlvbigneScpICsgbm9kZS5kYXRhKCdzaXplLWJlZm9yZS1jb2xsYXBzZScpLmggLyAyICsgcGFkZGluZ1xuICAgICAgICB9O1xuXG4gICAgICAgIHZhciB1bmlvbkJCID0gYm91bmRpbmdCb3hVdGlsaXRpZXMuZ2V0VW5pb24obm9kZUJCLCBiYik7XG4gICAgICAgIHZhciBhbmltYXRpbmcgPSBmYWxzZTtcblxuICAgICAgICBpZiAoIWJvdW5kaW5nQm94VXRpbGl0aWVzLmVxdWFsQm91bmRpbmdCb3hlcyh1bmlvbkJCLCBiYikpIHtcbiAgICAgICAgICB2YXIgdmlld1BvcnQgPSBjeS5nZXRGaXRWaWV3cG9ydCh1bmlvbkJCLCAxMCk7XG4gICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgICAgICAgIGFuaW1hdGluZyA9IGFuaW1hdGU7XG4gICAgICAgICAgaWYgKGFuaW1hdGUpIHtcbiAgICAgICAgICAgIGN5LmFuaW1hdGUoe1xuICAgICAgICAgICAgICBwYW46IHZpZXdQb3J0LnBhbixcbiAgICAgICAgICAgICAgem9vbTogdmlld1BvcnQuem9vbSxcbiAgICAgICAg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W2ldKSwgZG9JdChhY3Rpb25zWyhpICsgMykgJSA2XSkpO1xuICB9XG5cbn07XG4iXX0=
diff --git a/src/cueUtilities.js b/src/cueUtilities.js
index b21b510..05b2517 100644
--- a/src/cueUtilities.js
+++ b/src/cueUtilities.js
@@ -8,8 +8,8 @@ module.exports = function (params) {
init: function () {
var self = this;
var opts = params;
- var $container = $(this);
- var cy;
+ var $container = this;
+ var cy = this.cytoscape('get');
var $canvas = $('');
$container.append($canvas);
@@ -292,6 +292,7 @@ module.exports = function (params) {
$container.data('cyexpandcollapse', data);
},
unbind: function () {
+ var cy = this.cytoscape('get');
cy.off('mouseover', 'node', eMouseOver)
.off('mouseout tapdragout', 'node', eMouseOut)
.off('position', 'node', ePosition)
@@ -313,4 +314,4 @@ module.exports = function (params) {
}
return $(this);
-};
\ No newline at end of file
+};