-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Normalize zoom speed and wheel behavior across trace types #2041
Conversation
@@ -1332,6 +1332,7 @@ plots.purge = function(gd) { | |||
delete gd._transitionData; | |||
delete gd._transitioning; | |||
delete gd._initialAutoSize; | |||
delete gd._transitioningWithDuration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just one minor cleanup tweak I noticed along the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Thanks for doing this @rreusser 🎉
@@ -262,34 +262,27 @@ function createCamera(scene) { | |||
var lastX = result.lastPos[0], | |||
lastY = result.lastPos[1]; | |||
|
|||
switch(scene.fullLayout.dragmode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this gone? fullLayout.dragmode: false
should still be a thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, dragmode: false
isn't an option, is it? If I set that, it defaults to zoom
. This is removed for a slightly different reason though: because the dragmode should not be affecting mousewheel behavior at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh possible bug…… 🕷
When setting dragmode: false
with gl3d, dragging is disabled but gd._fullLayout.dragmode = 'zoom'
. That suggests it's sanitizing it but using gd.layout.dragmode
instead of gd._fullLayout.dragmode
. Actually setting dragmode: 'zoom'
behaves correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we only support layout.scene.dragmode: false
(ie 3D), not layout.dragmode: false
@rreusser good catch that this should not be disabled in zoom mode anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. It inherits false from layout.dragmode
despite layout.dragmode: false
not actually being a valid default. I'm okay with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oopppppppps, that line is in gl2d/camera.js
(i.e. NOT gl3d). Funny that thing has been there since v1.0.0.
🔪 🔪 🔪 🔪 🔪 🔪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Definitely undesirable. 😄 🔪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(next most glaring thing, as briefly mentioned to @alexcjohnson is double-click to revert zoom to autoscale, which is the top top top thing that always gets me about scattergl plots.)
Of course not sure the meaning/relevance once regl comes through, but still seems right given the relatively low effort involved for these tweaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is the top top top thing that always gets me about scattergl plots.)
No need to waste time on this. Double-click will just work after @dfcreative 's #1869
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Should have bothered to do it long ago, but I'm content to wait for #1869. 🎉
src/plots/gl2d/camera.js
Outdated
scene.relayoutCallback(); | ||
break; | ||
} | ||
var scale = Math.exp(scene.fullLayout.zoomspeed * 10.0 * dy / (viewBox[3] - viewBox[1])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Can we put that 10.0
in https://github.com/plotly/plotly.js/blob/master/src/constants/interactions.js ?
@@ -1332,6 +1332,7 @@ plots.purge = function(gd) { | |||
delete gd._transitionData; | |||
delete gd._transitioning; | |||
delete gd._initialAutoSize; | |||
delete gd._transitioningWithDuration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👌
Nice, definitely better parity this way. Playing with it now though, I wonder if something a little slower (maybe half this speed?) might be best for both versions. I still think you're right not to have it configurable though. Also, we decided long ago that 3D should have scroll zoom on always, but for SVG you need to have |
Mousewheel speed is a contentious issue. I'd support half speed for all. They at least felt same-ish Can you clarify the last point? For me when scrollZoom: false,
|
I think scatter and scattergl should match, but scatter3d should have wheel zoom enabled always. |
Okay, I've 1/2'd all zoom speeds (including svg, which previously wasn't affected by this PR) and |
👍 for me here. But, I think in |
Agreed. Including gl3d. I actually rather dislike scrollZoom being a config parameter. I find embedplot, for one, suddenly has dramatic scroll interactions I never saw when developing the plot. |
Okay, I'm now content with this. Had to fix test values. The big change is cartesian zoom speed *= 1/2. Which doesn't seem all that noticeable because of inertia. A much bigger change is gl zoom speed *= 5. |
💃 from my side. I have more thoughts about |
@rreusser what about those scroll factors. Looks like cartesian, gl2d and gl3d all use different one. Is that why you didn't bother putting them in a |
@etpinard Yes. I debated whether to copy the zoom factor logic. -camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0; Perhaps that should be modified to use the plot height and conform to the same math as SVG. |
No need. I was just curious why my comment didn't get addressed. I'm happy with the current state of this PR 💃 |
This PR attempts to normalize mouse wheel behavior across cartesian plots as well as gl2d and gl3d trace types. In particular, it:
makes zoom speed configurable throughEdit: no longer configurable; just fasterlayout.zoomspeed
(should this be a config parameter?)