Skip to content

3D surface plotly_relayout does not trigger with touch drag. Scroll zoom reports older camera vector. #5698

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

Open
Apivan opened this issue Jun 1, 2021 · 1 comment
Labels
bug something broken P3 backlog

Comments

@Apivan
Copy link

Apivan commented Jun 1, 2021

This is probably similar to #134
The plotly_relayout do trigger with mouse drag correctly.
However, this is not the case for touch drag.

To reproduce the problem please try open
https://plotly.com/javascript/3d-surface-plots/
and execute
document.getElementById("myDiv_1").on('plotly_relayout',()=>{console.log("relayout")});
you can see that the console doesn’t log when using touch emulator.

I also tested with https://cdn.plot.ly/plotly-latest. The problem is still reproducible.

plotly2

Another problem is mouse scroll zoom. The plotly report older camera vector. After subscribe to plotly_relayout, please then do mouse scroll zoom and execute

Plotly.relayout(document.getElementById("myDiv_1"), document.getElementById("myDiv_1")._fullLayout.scene.camera );

You will notice this the camera position is not always current. This is not problem when pan (right click drag) or rotate view.

@Apivan
Copy link
Author

Apivan commented Jun 1, 2021

Here is my quick fix.

diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js
index b7ee38712..f34f1a869 100644
--- a/src/plots/gl3d/scene.js
+++ b/src/plots/gl3d/scene.js
@@ -241,6 +241,10 @@ proto.initializeGLPlot = function() {
             relayoutCallback(scene);
         });
 
+        scene.glplot.canvas.addEventListener('touchend', function() {
+            relayoutCallback(scene);
+        });
+
         scene.glplot.canvas.addEventListener('wheel', function(e) {
             if(gd._context._scrollZoom.gl3d) {
                 if(scene.camera._ortho) {
@@ -253,7 +257,8 @@ proto.initializeGLPlot = function() {
                     });
                 }
 
-                relayoutCallback(scene);
+                setTimeout(()=>{ relayoutCallback(scene)},1000);
+               
             }
         }, passiveSupported ? {passive: false} : false);
 

@gvwilson gvwilson self-assigned this Jun 25, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added bug something broken P3 backlog labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants