Skip to content

Get click coordinate after a click with touch device #6721

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

Closed
josephernest opened this issue Sep 11, 2023 · 5 comments
Closed

Get click coordinate after a click with touch device #6721

josephernest opened this issue Sep 11, 2023 · 5 comments

Comments

@josephernest
Copy link

josephernest commented Sep 11, 2023

Let's say we have the select tool active on a heatmap. Live demo here, see the JS console.

We successfully get the coordinates:

  • when drag-and-drop: plotly_selected event => we have the coordinates in event.selections
  • when click: plotly_click event => we have the coordinates in event.points

When using a touchscreen, we also successfully get the coordinates when drag-and-drop: the plotly_selected event is fired and we have the coordinates in event.selections. But when clicking (=tap), we only get:

  • plotly_selected undefined, and no coordinate.

Question: I know that Plotly.js touch support is limited for now, but is there a way to get plotly_click event when we do a tap on a heatmap (with select tool), and have the coordinates in event.points?

PS: Even if I used an event listener with touch events (such as touchstart, touchend), I wouldn't get the coordinates in Plotly plot coordinate system.

@lvlte Maybe you have an idea? (I know you have experience in these topics!)

@josephernest
Copy link
Author

With touch (see here simulated with Dev Console), we only get coordinates when drag-and-drop, but not when single click/tap:

2023-09-12-0947-52.mp4

Is there a workaround for this?

With mouse, we get coordinates in both cases (drag-and-drop, and single pixel click):

2023-09-12-0925-12.mp4

@lvlte
Copy link
Contributor

lvlte commented Sep 12, 2023

Hi @josephernest, I did some tests and realized that with dragmode: "zoom" (default), plotly_click events are properly fired on touchscreen devices, whereas with dragmode: "select" they are not, even though the click is detected. This helped me find the involved code and I think I have found a fix, but I have to do some tests to be sure it won't break anything.

@josephernest
Copy link
Author

Thanks @lvlte, that's great! Feel free to send me the lines involved, I can try if it fixes it by just manually patching it. Thanks again!

@lvlte
Copy link
Contributor

lvlte commented Sep 14, 2023

@josephernest see the unique commit in the linked PR.

@archmoj
Copy link
Contributor

archmoj commented Oct 4, 2023

Fixed by #6724.

@archmoj archmoj closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants