Skip to content

Commit 89c1655

Browse files
committed
clear selection on zoom/pan
1 parent 698376e commit 89c1655

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/plots/cartesian/graph_interact.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
13891389
else if(dragModeNow === 'pan') {
13901390
dragOptions.moveFn = plotDrag;
13911391
dragOptions.doneFn = dragDone;
1392+
clearSelect();
13921393
}
13931394
else if(dragModeNow === 'select' || dragModeNow === 'lasso') {
13941395
prepSelect(e, startX, startY, dragOptions, dragModeNow);
@@ -1438,9 +1439,17 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
14381439
})
14391440
.attr('d','M0,0Z');
14401441

1442+
clearSelect();
14411443
for(i = 0; i < allaxes.length; i++) forceNumbers(allaxes[i].range);
14421444
}
14431445

1446+
function clearSelect() {
1447+
// until we get around to persistent selections, remove the outline
1448+
// here. The selection itself will be removed when the plot redraws
1449+
// at the end.
1450+
plotinfo.plot.selectAll('.select-outline').remove();
1451+
}
1452+
14441453
function zoomMove(dx0, dy0) {
14451454
var x1 = Math.max(0, Math.min(pw, dx0 + x0)),
14461455
y1 = Math.max(0, Math.min(ph, dy0 + y0)),

src/plots/cartesian/select.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
133133
};
134134

135135
dragOptions.doneFn = function(dragged, numclicks) {
136-
if(!dragged && numclicks === 2) dragOptions.doubleclick();
136+
if(!dragged && numclicks === 2) {
137+
// clear selection on doubleclick
138+
outlines.remove();
139+
for(i = 0; i < searchTraces.length; i++) {
140+
searchInfo = searchTraces[i];
141+
searchInfo.selectPoints(searchInfo, false);
142+
}
143+
}
137144
else {
138145
dragOptions.gd.emit('plotly_selected', eventData);
139146
}
140-
outlines.remove();
141147
corners.remove();
142-
for(i = 0; i < searchTraces.length; i++) {
143-
searchInfo = searchTraces[i];
144-
searchInfo.selectPoints(searchInfo, false);
145-
}
146148
};
147149
};
148150

0 commit comments

Comments
 (0)