From 82604eb29d7b9347d0d6ae65880617bdc6b7c09e Mon Sep 17 00:00:00 2001 From: Nick Tominaga Date: Wed, 12 Apr 2023 21:33:18 +0900 Subject: [PATCH 1/4] added tabletmode to fire plotly_click event for mobile devices. --- src/plots/gl3d/scene.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index 78be9c070d0..f45c12e78ae 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -24,6 +24,8 @@ var computeTickMarks = require('./layout/tick_marks'); var STATIC_CANVAS, STATIC_CONTEXT; +var tabletmode = false; + function Scene(options, fullLayout) { // create sub container for plot var sceneContainer = document.createElement('div'); @@ -241,6 +243,10 @@ proto.initializeGLPlot = function() { relayoutCallback(scene); }); + scene.glplot.canvas.addEventListener('touchstart', function() { + tabletmode = true; + }); + scene.glplot.canvas.addEventListener('wheel', function(e) { if(gd._context._scrollZoom.gl3d) { if(scene.camera._ortho) { @@ -448,7 +454,9 @@ proto.render = function() { pointData.bbox = bbox[0]; } - if(selection.buttons && selection.distance < 5) { + if(selection.buttons && selection.distance < 5 && !tabletmode) { + gd.emit('plotly_click', eventData); + }else if(tabletmode && selection.distance < 5) { gd.emit('plotly_click', eventData); } else { gd.emit('plotly_hover', eventData); From 735f8f27cd7a4808588d517c7158a17e47abd304 Mon Sep 17 00:00:00 2001 From: Nick Tominaga Date: Wed, 12 Apr 2023 22:24:21 +0900 Subject: [PATCH 2/4] eslinted --- src/plots/gl3d/scene.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index f45c12e78ae..82aa33f04ba 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -456,7 +456,7 @@ proto.render = function() { if(selection.buttons && selection.distance < 5 && !tabletmode) { gd.emit('plotly_click', eventData); - }else if(tabletmode && selection.distance < 5) { + } else if(tabletmode && selection.distance < 5) { gd.emit('plotly_click', eventData); } else { gd.emit('plotly_hover', eventData); From 2645334b59bbb64e21cb1cca02812f210692c682 Mon Sep 17 00:00:00 2001 From: Nick Tominaga Date: Thu, 20 Apr 2023 21:34:33 +0900 Subject: [PATCH 3/4] refactored condition for tabletmode --- draftlogs/6563_fix.md | 1 + src/plots/gl3d/scene.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 draftlogs/6563_fix.md diff --git a/draftlogs/6563_fix.md b/draftlogs/6563_fix.md new file mode 100644 index 00000000000..213c4c842a4 --- /dev/null +++ b/draftlogs/6563_fix.md @@ -0,0 +1 @@ + - fix condition of `plotly_click` to fire it on touch devices [[#6563](https://github.com/plotly/plotly.js/pull/6563)] diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index 82aa33f04ba..285f2e1c425 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -454,9 +454,7 @@ proto.render = function() { pointData.bbox = bbox[0]; } - if(selection.buttons && selection.distance < 5 && !tabletmode) { - gd.emit('plotly_click', eventData); - } else if(tabletmode && selection.distance < 5) { + if(selection.distance < 5 && (selection.buttons || tabletmode)) { gd.emit('plotly_click', eventData); } else { gd.emit('plotly_hover', eventData); From 37df028691e0fc25f6b3e455210d7351462c7059 Mon Sep 17 00:00:00 2001 From: Nick Tominaga Date: Fri, 21 Apr 2023 21:49:35 +0900 Subject: [PATCH 4/4] Update draftlogs/6563_fix.md Co-authored-by: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com> --- draftlogs/6563_fix.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/draftlogs/6563_fix.md b/draftlogs/6563_fix.md index 213c4c842a4..e51aedbbcd2 100644 --- a/draftlogs/6563_fix.md +++ b/draftlogs/6563_fix.md @@ -1 +1,2 @@ - - fix condition of `plotly_click` to fire it on touch devices [[#6563](https://github.com/plotly/plotly.js/pull/6563)] + - fix `plotly_click` in gl3d scenes to fire on touch devices [[#6563](https://github.com/plotly/plotly.js/pull/6563)], + with thanks to @NickTominaga for the contribution!