Skip to content

Commit f682fb8

Browse files
committed
clear selectio polygon cache on scroll
1 parent ffe1700 commit f682fb8

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/plots/cartesian/dragbox.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
178178
prepSelect(e, startX, startY, dragOptions, dragModeNow);
179179
} else {
180180
dragOptions.clickFn = clickFn;
181-
// clear selection polygon cache (if any)
182-
plotinfo.selection = false;
183181

184182
if(allFixedRanges) {
185-
clearSelect(zoomlayer);
183+
clearAndResetSelect();
186184
} else if(dragModeNow === 'zoom') {
187185
dragOptions.moveFn = zoomMove;
188186
dragOptions.doneFn = zoomDone;
@@ -196,11 +194,18 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
196194
} else if(dragModeNow === 'pan') {
197195
dragOptions.moveFn = plotDrag;
198196
dragOptions.doneFn = dragTail;
199-
clearSelect(zoomlayer);
197+
clearAndResetSelect();
200198
}
201199
}
202200
};
203201

202+
function clearAndResetSelect() {
203+
// clear selection polygon cache (if any)
204+
dragOptions.plotinfo.selection = false;
205+
// clear selection outlines
206+
clearSelect(zoomlayer);
207+
}
208+
204209
function clickFn(numClicks, evt) {
205210
removeZoombox(gd);
206211

@@ -281,7 +286,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
281286

282287
corners = makeCorners(zoomlayer, xs, ys);
283288

284-
clearSelect(zoomlayer);
289+
clearAndResetSelect();
285290
}
286291

287292
function zoomMove(dx0, dy0) {
@@ -393,7 +398,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
393398
return;
394399
}
395400

396-
clearSelect(zoomlayer);
401+
clearAndResetSelect();
397402

398403
// If a transition is in progress, then disable any behavior:
399404
if(gd._transitioningWithDuration) {

test/jasmine/tests/select_test.js

+11
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ describe('@flaky Test select box and lasso in general:', function() {
745745
fig.layout.width = 500;
746746
fig.layout.height = 500;
747747
fig.layout.dragmode = 'select';
748+
fig.config = {scrollZoom: true};
748749

749750
// d attr to array of segment [x,y]
750751
function outline2coords(outline) {
@@ -856,6 +857,16 @@ describe('@flaky Test select box and lasso in general:', function() {
856857
]
857858
});
858859
})
860+
.then(function() {
861+
mouseEvent('mousemove', 200, 200);
862+
mouseEvent('scroll', 200, 200, {deltaX: 0, deltaY: -20});
863+
})
864+
.then(_drag(path1, {shiftKey: true}))
865+
.then(function() {
866+
_assert('shift select path1 after scroll', {
867+
outline: [[150, 150], [150, 170], [170, 170], [170, 150], [150, 150]]
868+
});
869+
})
859870
.catch(failTest)
860871
.then(done);
861872
});

0 commit comments

Comments
 (0)