Skip to content

Commit 45a4d98

Browse files
authored
Merge pull request #6563 from NickTominaga/touchevent_on_scatter3d
added tabletmode to fire plotly_click event for mobile devices.
2 parents 55dda47 + 37df028 commit 45a4d98

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

draftlogs/6563_fix.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- fix `plotly_click` in gl3d scenes to fire on touch devices [[#6563](https://github.com/plotly/plotly.js/pull/6563)],
2+
with thanks to @NickTominaga for the contribution!

src/plots/gl3d/scene.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ var computeTickMarks = require('./layout/tick_marks');
2424

2525
var STATIC_CANVAS, STATIC_CONTEXT;
2626

27+
var tabletmode = false;
28+
2729
function Scene(options, fullLayout) {
2830
// create sub container for plot
2931
var sceneContainer = document.createElement('div');
@@ -241,6 +243,10 @@ proto.initializeGLPlot = function() {
241243
relayoutCallback(scene);
242244
});
243245

246+
scene.glplot.canvas.addEventListener('touchstart', function() {
247+
tabletmode = true;
248+
});
249+
244250
scene.glplot.canvas.addEventListener('wheel', function(e) {
245251
if(gd._context._scrollZoom.gl3d) {
246252
if(scene.camera._ortho) {
@@ -448,7 +454,7 @@ proto.render = function() {
448454
pointData.bbox = bbox[0];
449455
}
450456

451-
if(selection.buttons && selection.distance < 5) {
457+
if(selection.distance < 5 && (selection.buttons || tabletmode)) {
452458
gd.emit('plotly_click', eventData);
453459
} else {
454460
gd.emit('plotly_hover', eventData);

0 commit comments

Comments
 (0)