Skip to content

Commit

Permalink
fixup cross-subplot select logic brought up in 71a0395
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Apr 12, 2018
1 parent 24dad16 commit 9d0bcfd
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,33 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
var filterPoly, testPoly, mergedPolygons, currentPolygon;
var i, cd, trace, searchInfo, eventData;

if(fullLayout._lastSelectedSubplot && fullLayout._lastSelectedSubplot === plotinfo.id) {
var selectingOnSameSubplot = (
fullLayout._lastSelectedSubplot &&
fullLayout._lastSelectedSubplot === plotinfo.id
);

if(
selectingOnSameSubplot &&
(e.shiftKey || e.altKey) &&
(plotinfo.selection && plotinfo.selection.polygons) &&
!dragOptions.polygons
) {
// take over selection polygons from prev mode, if any
if((e.shiftKey || e.altKey) && (plotinfo.selection && plotinfo.selection.polygons) && !dragOptions.polygons) {
dragOptions.polygons = plotinfo.selection.polygons;
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
}
// create new polygons, if shift mode
else if((!e.shiftKey && !e.altKey) || ((e.shiftKey || e.altKey) && !plotinfo.selection)) {
plotinfo.selection = {};
plotinfo.selection.polygons = dragOptions.polygons = [];
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
}
} else {
// do not allow multi-selection across different subplots
dragOptions.polygons = plotinfo.selection.polygons;
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
} else if(
(!e.shiftKey && !e.altKey) ||
((e.shiftKey || e.altKey) &&
!plotinfo.selection)
) {
// create new polygons, if shift mode or selecting across different subplots
plotinfo.selection = {};
plotinfo.selection.polygons = dragOptions.polygons = [];
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
}

// clear selection outline when selecting a different subplot
if(!selectingOnSameSubplot) {
clearSelect(zoomLayer);
fullLayout._lastSelectedSubplot = plotinfo.id;
}
Expand Down

0 comments on commit 9d0bcfd

Please sign in to comment.