Skip to content

Commit

Permalink
Redraw cue after undo or redo
Browse files Browse the repository at this point in the history
  Adresses iVis-at-Bilkent/newt#634

  Solves an issue where the cue wouldn't be redrawn after undo/redo
  operations that change the node width/height which change the
  position where the cue should be drawn.
  • Loading branch information
msalihaltun committed Nov 4, 2020
1 parent 9ad46ef commit b807438
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
23 changes: 15 additions & 8 deletions cytoscape-expand-collapse.js

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions src/cueUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,14 @@ module.exports = function (params, cy, api) {
if (nodeWithRenderedCue) {
clearDraws();
}
var isOnly1Selected = cy.$(':selected').length == 1;
var isOnly1SelectedCompundNode = cy.nodes(':parent').filter(':selected').length == 1 && isOnly1Selected;
var isOnly1SelectedCollapsedNode = cy.nodes('.cy-expand-collapse-collapsed-node').filter(':selected').length == 1 && isOnly1Selected;
if (isOnly1SelectedCollapsedNode || isOnly1SelectedCompundNode) {
drawExpandCollapseCue(cy.nodes(':selected')[0]);
var selectedNodes = cy.nodes(':selected');
if (selectedNodes.length !== 1) {
return;
}
var selectedNode = selectedNodes[0];

if (selectedNode.isParent() || selectedNode.hasClass('cy-expand-collapse-collapsed-node')) {
drawExpandCollapseCue(selectedNode);
}
});

Expand Down Expand Up @@ -282,6 +285,8 @@ module.exports = function (params, cy, api) {
}
});

cy.on('afterUndo afterRedo', data.eUndoRedo = data.eSelect);

cy.on('position', 'node', data.ePosition = debounce2(data.eSelect, CUE_POS_UPDATE_DELAY, clearDraws));

cy.on('pan zoom', data.ePosition);
Expand Down Expand Up @@ -310,7 +315,8 @@ module.exports = function (params, cy, api) {
.off('pan zoom', data.ePosition)
.off('select unselect', data.eSelect)
.off('free', 'node', data.eFree)
.off('resize', data.eCyResize);
.off('resize', data.eCyResize)
.off('afterUndo afterRedo', data.eUndoRedo);
},
rebind: function () {
var data = getData();
Expand All @@ -329,7 +335,8 @@ module.exports = function (params, cy, api) {
.on('pan zoom', data.ePosition)
.on('select unselect', data.eSelect)
.on('free', 'node', data.eFree)
.on('resize', data.eCyResize);
.on('resize', data.eCyResize)
.on('afterUndo afterRedo', data.eUndoRedo);
}
};

Expand Down

0 comments on commit b807438

Please sign in to comment.