Skip to content

Commit 869a42f

Browse files
committed
pass gd to clearSelect
... instead of `zoomlayer`, making it easier to reuse.
1 parent ec82529 commit 869a42f

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

src/plot_api/plot_api.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,13 +1994,8 @@ function addAxRangeSequence(seq, rangesAltered) {
19941994
return Axes.draw(gd, 'redraw');
19951995
};
19961996

1997-
var _clearSelect = function(gd) {
1998-
var zoomlayer = gd._fullLayout._zoomlayer;
1999-
if(zoomlayer) clearSelect(zoomlayer);
2000-
};
2001-
20021997
seq.push(
2003-
_clearSelect,
1998+
clearSelect,
20041999
subroutines.doAutoRangeAndConstraints,
20052000
drawAxes,
20062001
subroutines.drawData,

src/plots/cartesian/dragbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
222222
// clear selection polygon cache (if any)
223223
dragOptions.plotinfo.selection = false;
224224
// clear selection outlines
225-
clearSelect(zoomlayer);
225+
clearSelect(gd);
226226
}
227227

228228
function clickFn(numClicks, evt) {

src/plots/cartesian/select.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ function multiTester(list) {
465465

466466
function coerceSelectionsCache(evt, gd, dragOptions) {
467467
var fullLayout = gd._fullLayout;
468-
var zoomLayer = fullLayout._zoomlayer;
469468
var plotinfo = dragOptions.plotinfo;
470469

471470
var selectingOnSameSubplot = (
472-
fullLayout._lastSelectedSubplot &&
473-
fullLayout._lastSelectedSubplot === plotinfo.id
471+
fullLayout._lastSelectedSubplot &&
472+
fullLayout._lastSelectedSubplot === plotinfo.id
474473
);
475474
var hasModifierKey = evt.shiftKey || evt.altKey;
475+
476476
if(selectingOnSameSubplot && hasModifierKey &&
477477
(plotinfo.selection && plotinfo.selection.selectionDefs) && !dragOptions.selectionDefs) {
478478
// take over selection definitions from prev mode, if any
@@ -484,7 +484,7 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
484484

485485
// clear selection outline when selecting a different subplot
486486
if(!selectingOnSameSubplot) {
487-
clearSelect(zoomLayer);
487+
clearSelect(gd);
488488
fullLayout._lastSelectedSubplot = plotinfo.id;
489489
}
490490
}
@@ -774,11 +774,15 @@ function fillSelectionItem(selection, searchInfo) {
774774
return selection;
775775
}
776776

777-
function clearSelect(zoomlayer) {
778-
// until we get around to persistent selections, remove the outline
779-
// here. The selection itself will be removed when the plot redraws
780-
// at the end.
781-
zoomlayer.selectAll('.select-outline').remove();
777+
// until we get around to persistent selections, remove the outline
778+
// here. The selection itself will be removed when the plot redraws
779+
// at the end.
780+
function clearSelect(gd) {
781+
var fullLayout = gd._fullLayout || {};
782+
var zoomlayer = fullLayout._zoomlayer;
783+
if(zoomlayer) {
784+
zoomlayer.selectAll('.select-outline').remove();
785+
}
782786
}
783787

784788
module.exports = {

src/plots/polar/polar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ proto.updateMainDrag = function(fullLayout) {
795795
zb = dragBox.makeZoombox(zoomlayer, lum, cx, cy, path0);
796796
zb.attr('fill-rule', 'evenodd');
797797
corners = dragBox.makeCorners(zoomlayer, cx, cy);
798-
clearSelect(zoomlayer);
798+
clearSelect(gd);
799799
}
800800

801801
// N.B. this sets scoped 'r0' and 'r1'
@@ -1115,7 +1115,7 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) {
11151115
dragOpts.moveFn = moveFn;
11161116
dragOpts.doneFn = doneFn;
11171117

1118-
clearSelect(fullLayout._zoomlayer);
1118+
clearSelect(gd);
11191119
};
11201120

11211121
dragOpts.clampFn = function(dx, dy) {
@@ -1263,7 +1263,7 @@ proto.updateAngularDrag = function(fullLayout) {
12631263
dragOpts.moveFn = moveFn;
12641264
dragOpts.doneFn = doneFn;
12651265

1266-
clearSelect(fullLayout._zoomlayer);
1266+
clearSelect(gd);
12671267
};
12681268

12691269
// I don't what we should do in this case, skip we now

src/plots/ternary/ternary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ proto.initInteractions = function() {
526526
dragOptions.clickFn = clickZoomPan;
527527
dragOptions.doneFn = dragDone;
528528
panPrep();
529-
clearSelect(zoomContainer);
529+
clearSelect(gd);
530530
}
531531
else if(dragModeNow === 'select' || dragModeNow === 'lasso') {
532532
prepSelect(e, startX, startY, dragOptions, dragModeNow);
@@ -598,7 +598,7 @@ proto.initInteractions = function() {
598598
})
599599
.attr('d', 'M0,0Z');
600600

601-
clearSelect(zoomContainer);
601+
clearSelect(gd);
602602
}
603603

604604
function getAFrac(x, y) { return 1 - (y / _this.h); }

0 commit comments

Comments
 (0)