Skip to content

Commit 7221cd0

Browse files
committed
Prevent event, mute logging
1 parent f3806b9 commit 7221cd0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/plots/gl3d/camera.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var createView = require('3d-view');
1515
var mouseChange = require('mouse-change');
1616
var mouseWheel = require('mouse-wheel');
1717
var mouseOffset = require('mouse-event-offset');
18+
var Lib = require('../../lib');
19+
var supportsPassive = Lib.eventListenerOptionsSupported();
1820

1921
function createCamera(element, options) {
2022
element = element || document.body;
@@ -188,14 +190,20 @@ function createCamera(element, options) {
188190
var xy = mouseOffset(ev.changedTouches[0], element);
189191
handleInteraction(0, xy[0], xy[1], lastMods);
190192
handleInteraction(1, xy[0], xy[1], lastMods);
191-
});
193+
194+
ev.preventDefault();
195+
}, supportsPassive ? {passive: false} : false);
192196
element.addEventListener('touchmove', function(ev) {
193197
var xy = mouseOffset(ev.changedTouches[0], element);
194198
handleInteraction(1, xy[0], xy[1], lastMods);
195-
});
196-
element.addEventListener('touchend', function() {
199+
200+
ev.preventDefault();
201+
}, supportsPassive ? {passive: false} : false);
202+
element.addEventListener('touchend', function(ev) {
197203
handleInteraction(0, lastX, lastY, lastMods);
198-
});
204+
205+
ev.preventDefault();
206+
}, supportsPassive ? {passive: false} : false);
199207

200208
function handleInteraction(buttons, x, y, mods) {
201209
var keyBindingMode = camera.keyBindingMode;

src/plots/gl3d/scene.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ var createAxesOptions = require('./layout/convert');
2727
var createSpikeOptions = require('./layout/spikes');
2828
var computeTickMarks = require('./layout/tick_marks');
2929

30+
var passiveSupported = Lib.eventListenerOptionsSupported();
31+
3032
var STATIC_CANVAS, STATIC_CONTEXT;
3133

3234
function render(scene) {
@@ -190,7 +192,7 @@ function initializeGLPlot(scene, fullLayout, canvas, gl) {
190192
};
191193

192194
scene.glplot.canvas.addEventListener('mouseup', relayoutCallback.bind(null, scene));
193-
scene.glplot.canvas.addEventListener('wheel', relayoutCallback.bind(null, scene));
195+
scene.glplot.canvas.addEventListener('wheel', relayoutCallback.bind(null, scene), passiveSupported ? {passive: false} : false);
194196

195197
if(!scene.staticMode) {
196198
scene.glplot.canvas.addEventListener('webglcontextlost', function(ev) {

0 commit comments

Comments
 (0)