Skip to content

Commit 5f80b6e

Browse files
committed
dry: check for if dragbox is main-drag only once
1 parent fdb0c3c commit 5f80b6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/plots/cartesian/dragbox.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
5252
pw = xa[0]._length,
5353
ph = ya[0]._length,
5454
MINDRAG = constants.MINDRAG,
55-
MINZOOM = constants.MINZOOM;
55+
MINZOOM = constants.MINZOOM,
56+
isMainDrag = (ns + ew === 'nsew');
5657

5758
for(var i = 1; i < subplots.length; i++) {
5859
var subplotXa = subplots[i].x(),
@@ -89,7 +90,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
8990
// and stop there
9091
if(!yActive && !xActive) {
9192
dragger.onmousedown = null;
92-
dragger.style.pointerEvents = (ns + ew === 'nsew') ? 'all' : 'none';
93+
dragger.style.pointerEvents = isMainDrag ? 'all' : 'none';
9394
return dragger;
9495
}
9596

@@ -107,7 +108,8 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
107108
doubleclick: doubleClick,
108109
prepFn: function(e, startX, startY) {
109110
var dragModeNow = gd._fullLayout.dragmode;
110-
if(ns + ew === 'nsew') {
111+
112+
if(isMainDrag) {
111113
// main dragger handles all drag modes, and changes
112114
// to pan (or to zoom if it already is pan) on shift
113115
if(e.shiftKey) {

0 commit comments

Comments
 (0)