Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b3102ac

Browse filesBrowse files
committed
re-enable click for fixedrange plots
1 parent e701b5e commit b3102ac
Copy full SHA for b3102ac

File tree

Expand file treeCollapse file tree

2 files changed

+51
-19
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+51
-19
lines changed

‎src/plots/cartesian/dragbox.js

Copy file name to clipboardExpand all lines: src/plots/cartesian/dragbox.js
+26-19Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
113113

114114
var dragger = makeRectDragger(plotinfo, ns + ew + 'drag', cursor, x, y, w, h);
115115

116+
var allFixedRanges = !yActive && !xActive;
117+
116118
// still need to make the element if the axes are disabled
117119
// but nuke its events (except for maindrag which needs them for hover)
118120
// and stop there
119-
if(!yActive && !xActive && !isSelectOrLasso(fullLayout.dragmode)) {
121+
if(allFixedRanges && !isMainDrag) {
120122
dragger.onmousedown = null;
121-
dragger.style.pointerEvents = isMainDrag ? 'all' : 'none';
123+
dragger.style.pointerEvents = 'none';
122124
return dragger;
123125
}
124126

@@ -129,24 +131,34 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
129131
prepFn: function(e, startX, startY) {
130132
var dragModeNow = gd._fullLayout.dragmode;
131133

132-
if(isMainDrag) {
133-
// main dragger handles all drag modes, and changes
134-
// to pan (or to zoom if it already is pan) on shift
135-
if(e.shiftKey) {
136-
if(dragModeNow === 'pan') dragModeNow = 'zoom';
137-
else if(!isSelectOrLasso(dragModeNow)) dragModeNow = 'pan';
138-
}
139-
else if(e.ctrlKey) {
140-
dragModeNow = 'pan';
134+
if(!allFixedRanges) {
135+
if(isMainDrag) {
136+
// main dragger handles all drag modes, and changes
137+
// to pan (or to zoom if it already is pan) on shift
138+
if(e.shiftKey) {
139+
if(dragModeNow === 'pan') dragModeNow = 'zoom';
140+
else if(!isSelectOrLasso(dragModeNow)) dragModeNow = 'pan';
141+
}
142+
else if(e.ctrlKey) {
143+
dragModeNow = 'pan';
144+
}
141145
}
146+
// all other draggers just pan
147+
else dragModeNow = 'pan';
142148
}
143-
// all other draggers just pan
144-
else dragModeNow = 'pan';
145149

146150
if(dragModeNow === 'lasso') dragOptions.minDrag = 1;
147151
else dragOptions.minDrag = undefined;
148152

149-
if(dragModeNow === 'zoom') {
153+
if(isSelectOrLasso(dragModeNow)) {
154+
dragOptions.xaxes = xa;
155+
dragOptions.yaxes = ya;
156+
prepSelect(e, startX, startY, dragOptions, dragModeNow);
157+
}
158+
else if(allFixedRanges) {
159+
clearSelect(zoomlayer);
160+
}
161+
else if(dragModeNow === 'zoom') {
150162
dragOptions.moveFn = zoomMove;
151163
dragOptions.doneFn = zoomDone;
152164

@@ -162,11 +174,6 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
162174
dragOptions.doneFn = dragTail;
163175
clearSelect(zoomlayer);
164176
}
165-
else if(isSelectOrLasso(dragModeNow)) {
166-
dragOptions.xaxes = xa;
167-
dragOptions.yaxes = ya;
168-
prepSelect(e, startX, startY, dragOptions, dragModeNow);
169-
}
170177
},
171178
clickFn: function(numClicks, evt) {
172179
removeZoombox(gd);

‎test/jasmine/tests/click_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/click_test.js
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,31 @@ describe('Test click interactions:', function() {
138138
expect(evt.clientY).toEqual(pointPos[1]);
139139
});
140140

141+
it('works with fixedrange axes', function(done) {
142+
Plotly.relayout(gd, {'xaxis.fixedrange': true, 'yaxis.fixedrange': true}).then(function() {
143+
click(pointPos[0], pointPos[1]);
144+
expect(futureData.points.length).toEqual(1);
145+
expect(clickPassthroughs).toBe(2);
146+
expect(contextPassthroughs).toBe(0);
147+
148+
var pt = futureData.points[0];
149+
expect(Object.keys(pt)).toEqual([
150+
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
151+
'x', 'y', 'xaxis', 'yaxis'
152+
]);
153+
expect(pt.curveNumber).toEqual(0);
154+
expect(pt.pointNumber).toEqual(11);
155+
expect(pt.x).toEqual(0.125);
156+
expect(pt.y).toEqual(2.125);
157+
158+
var evt = futureData.event;
159+
expect(evt.clientX).toEqual(pointPos[0]);
160+
expect(evt.clientY).toEqual(pointPos[1]);
161+
})
162+
.catch(fail)
163+
.then(done);
164+
});
165+
141166
var modClickOpts = {
142167
altKey: true,
143168
ctrlKey: true, // this makes it effectively into a right-click

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.