Skip to content

Commit 20820cb

Browse files
committed
reassign zoom/pan clickFn when switching from select/lasso mode
1 parent 0cad1fe commit 20820cb

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

src/plots/cartesian/dragbox.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,32 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
174174
if(isSelectOrLasso(dragModeNow)) {
175175
dragOptions.xaxes = xaxes;
176176
dragOptions.yaxes = yaxes;
177+
// this attaches moveFn, clickFn, doneFn on dragOptions
177178
prepSelect(e, startX, startY, dragOptions, dragModeNow);
178-
}
179-
else if(allFixedRanges) {
180-
clearSelect(zoomlayer);
181-
}
182-
else if(dragModeNow === 'zoom') {
183-
dragOptions.moveFn = zoomMove;
184-
dragOptions.doneFn = zoomDone;
185-
186-
// zoomMove takes care of the threshold, but we need to
187-
// minimize this so that constrained zoom boxes will flip
188-
// orientation at the right place
189-
dragOptions.minDrag = 1;
190-
191-
zoomPrep(e, startX, startY);
192-
}
193-
else if(dragModeNow === 'pan') {
194-
dragOptions.moveFn = plotDrag;
195-
dragOptions.doneFn = dragTail;
196-
clearSelect(zoomlayer);
179+
} else {
180+
dragOptions.clickFn = clickFn;
181+
182+
if(allFixedRanges) {
183+
clearSelect(zoomlayer);
184+
} else if(dragModeNow === 'zoom') {
185+
dragOptions.moveFn = zoomMove;
186+
dragOptions.doneFn = zoomDone;
187+
188+
// zoomMove takes care of the threshold, but we need to
189+
// minimize this so that constrained zoom boxes will flip
190+
// orientation at the right place
191+
dragOptions.minDrag = 1;
192+
193+
zoomPrep(e, startX, startY);
194+
} else if(dragModeNow === 'pan') {
195+
dragOptions.moveFn = plotDrag;
196+
dragOptions.doneFn = dragTail;
197+
clearSelect(zoomlayer);
198+
}
197199
}
198200
};
199201

200-
dragOptions.clickFn = function(numClicks, evt) {
202+
function clickFn(numClicks, evt) {
201203
removeZoombox(gd);
202204

203205
if(numClicks === 2 && !singleEnd) doubleClick();
@@ -240,7 +242,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
240242
});
241243
}
242244
}
243-
};
245+
}
244246

245247
dragElement.init(dragOptions);
246248

0 commit comments

Comments
 (0)