Skip to content

added tabletmode to fire plotly_click event for mobile devices. #6563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.
Could we possibly combine the two if statements for plotly_click like this?

        if(selection.distance < 5 && (selection.buttons || tabletmode)) {
            gd.emit('plotly_click', eventData);
        } else {
            gd.emit('plotly_hover', eventData);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review I just updated the code and added draft log but probably I misunderstood the usage of the changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like my suggestion caused the tests to fail.
Let's revert that part but please keep the draftlog.
And we should ready to go 🚀
Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I just took your review which only changed draftlogs but the test passed. The same thing happened between 82604eb and 735f8f2

In that commit I just eslinted but the test passed too. webgl-jasmine fails sometimes. weird...

gd.emit('plotly_click', eventData);
} else {
gd.emit('plotly_hover', eventData);
Expand Down