Skip to content

Commit 7e6e899

Browse files
Alex VinoberAlex Vinober
Alex Vinober
authored and
Alex Vinober
committed
Check if not a left-click, then bail out of onStart
1 parent c3f0a18 commit 7e6e899

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/components/dragelement/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ dragElement.init = function init(options) {
7878
element.ontouchstart = onStart;
7979

8080
function onStart(e) {
81+
if(e.button && e.button === 2) { // right click
82+
return;
83+
}
84+
8185
// make dragging and dragged into properties of gd
8286
// so that others can look at and modify them
8387
gd._dragged = false;

test/jasmine/tests/dragelement_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ describe('dragElement', function() {
122122
expect(countCoverSlip()).toEqual(0);
123123
});
124124

125+
it('should not add a cover slip div to the DOM when right click', function() {
126+
function countCoverSlip() {
127+
return d3.selectAll('.dragcover').size();
128+
}
129+
130+
var options = { element: this.element, gd: this.gd };
131+
dragElement.init(options);
132+
133+
options.element.onmousedown({button: 2})
134+
135+
expect(countCoverSlip()).toEqual(0);
136+
});
137+
125138
it('should fire off click event when down/up without dragging', function() {
126139
var options = { element: this.element, gd: this.gd };
127140
dragElement.init(options);

0 commit comments

Comments
 (0)