Skip to content

Commit eb290e9

Browse files
committed
fix edge cases from failing tests
1 parent 3194dba commit eb290e9

4 files changed

Lines changed: 34 additions & 12 deletions

File tree

‎src/plots/geo/zoom.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function startDragStyle(geo, el) {
1414
d3.select(el).style(zoomstartStyle);
1515

1616
var sourceEvent = d3.event.sourceEvent;
17-
if(sourceEvent && sourceEvent.type === 'mousedown') {
17+
var isRightClick = sourceEvent && (sourceEvent.buttons === 2 || sourceEvent.ctrlKey);
18+
if(sourceEvent && sourceEvent.type === 'mousedown' && !isRightClick) {
1819
geo._dragCover = dragElement.coverSlip();
1920
geo._dragCover.style.cursor = zoomstartStyle.cursor;
2021
}

‎src/traces/parcoords/axisbrush.js‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function dragstart(lThis, d) {
226226
s.startExtent = interval.region ? unitRange[interval.region === 's' ? 1 : 0] : unitLocation;
227227
d.parent.inBrushDrag = true;
228228
s.dragCover = dragElement.coverSlip();
229-
s.dragCover.style.cursor = window.getComputedStyle(lThis).cursor;
229+
s.dragCover.style.cursor = getCursor(interval);
230230
s.brushStartCallback();
231231
}
232232

@@ -328,14 +328,15 @@ function dragend(lThis, d) {
328328
s.brushEndCallback(brush.filterSpecified ? filter.getConsolidated() : []);
329329
}
330330

331+
function getCursor(interval) {
332+
if(interval.clickableOrdinalRange) return 'pointer';
333+
if(interval.region) return interval.region + '-resize';
334+
return 'crosshair';
335+
}
336+
331337
function mousemove(lThis, d) {
332338
var y = d.height - d3.mouse(lThis)[1] - 2 * c.verticalPadding;
333-
var interval = getInterval(d, y);
334-
335-
var cursor = 'crosshair';
336-
if(interval.clickableOrdinalRange) cursor = 'pointer';
337-
else if(interval.region) cursor = interval.region + '-resize';
338-
setCursor(d3.select(lThis), cursor);
339+
setCursor(d3.select(lThis), getCursor(getInterval(d, y)));
339340
}
340341

341342
function attachDragBehavior(selection) {

‎test/jasmine/tests/fx_test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,19 @@ describe('relayout', function() {
310310
return Plotly.relayout(gd, 'yaxis.fixedrange', true);
311311
}).then(function() {
312312
// still active with fixedrange because we're handling clicks here too.
313-
assertMainDrag('pointer', true);
313+
assertMainDrag('default', true);
314314

315315
return Plotly.relayout(gd, 'dragmode', 'drag');
316316
}).then(function() {
317-
assertMainDrag('pointer', true);
317+
assertMainDrag('default', true);
318318

319319
return Plotly.relayout(gd, 'dragmode', 'lasso');
320320
}).then(function() {
321-
assertMainDrag('pointer', true);
321+
assertMainDrag('default', true);
322322

323323
return Plotly.relayout(gd, 'dragmode', 'select');
324324
}).then(function() {
325-
assertMainDrag('pointer', true);
325+
assertMainDrag('default', true);
326326

327327
return Plotly.relayout(gd, 'xaxis.fixedrange', false);
328328
}).then(function() {

‎test/jasmine/tests/geo_test.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,26 @@ describe('Test geo interactions', function () {
16901690
.then(done, done.fail);
16911691
});
16921692

1693+
it('should not create a drag cover on right-click', function (done) {
1694+
var gd = createGraphDiv();
1695+
var fig = Lib.extendDeep({}, require('../../image/mocks/geo_orthographic.json'));
1696+
fig.layout.width = 700;
1697+
fig.layout.height = 500;
1698+
fig.layout.dragmode = 'pan';
1699+
1700+
Plotly.newPlot(gd, fig)
1701+
.then(function () {
1702+
mouseEvent('mousedown', 350, 250, { buttons: 2 });
1703+
expect(document.querySelectorAll('.dragcover').length).toBe(0, 'right button');
1704+
mouseEvent('mouseup', 350, 250, { buttons: 2 });
1705+
1706+
mouseEvent('mousedown', 350, 250, { ctrlKey: true });
1707+
expect(document.querySelectorAll('.dragcover').length).toBe(0, 'ctrl key');
1708+
mouseEvent('mouseup', 350, 250, { ctrlKey: true });
1709+
})
1710+
.then(done, done.fail);
1711+
});
1712+
16931713
it('should clear hover label when cursor slips off subplot', function (done) {
16941714
var gd = createGraphDiv();
16951715
var fig = Lib.extendDeep({}, require('../../image/mocks/geo_orthographic.json'));

0 commit comments

Comments
 (0)