-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Normalize zoom speed and wheel behavior across trace types #2041
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
Changes from 1 commit
394014e
e489a72
99101fe
e231233
8ddb965
4265a38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,34 +262,27 @@ function createCamera(scene) { | |
var lastX = result.lastPos[0], | ||
lastY = result.lastPos[1]; | ||
|
||
switch(scene.fullLayout.dragmode) { | ||
case 'zoom': | ||
break; | ||
|
||
case 'pan': | ||
var scale = Math.exp(0.1 * dy / (viewBox[3] - viewBox[1])); | ||
|
||
var cx = lastX / | ||
(viewBox[2] - viewBox[0]) * (dataBox[2] - dataBox[0]) + | ||
dataBox[0]; | ||
var cy = lastY / | ||
(viewBox[3] - viewBox[1]) * (dataBox[3] - dataBox[1]) + | ||
dataBox[1]; | ||
|
||
dataBox[0] = (dataBox[0] - cx) * scale + cx; | ||
dataBox[2] = (dataBox[2] - cx) * scale + cx; | ||
dataBox[1] = (dataBox[1] - cy) * scale + cy; | ||
dataBox[3] = (dataBox[3] - cy) * scale + cy; | ||
|
||
scene.setRanges(dataBox); | ||
|
||
result.lastInputTime = Date.now(); | ||
unSetAutoRange(); | ||
scene.cameraChanged(); | ||
scene.handleAnnotations(); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Nice. Can we put that |
||
|
||
var cx = lastX / | ||
(viewBox[2] - viewBox[0]) * (dataBox[2] - dataBox[0]) + | ||
dataBox[0]; | ||
var cy = lastY / | ||
(viewBox[3] - viewBox[1]) * (dataBox[3] - dataBox[1]) + | ||
dataBox[1]; | ||
|
||
dataBox[0] = (dataBox[0] - cx) * scale + cx; | ||
dataBox[2] = (dataBox[2] - cx) * scale + cx; | ||
dataBox[1] = (dataBox[1] - cy) * scale + cy; | ||
dataBox[3] = (dataBox[3] - cy) * scale + cy; | ||
|
||
scene.setRanges(dataBox); | ||
|
||
result.lastInputTime = Date.now(); | ||
unSetAutoRange(); | ||
scene.cameraChanged(); | ||
scene.handleAnnotations(); | ||
scene.relayoutCallback(); | ||
|
||
return true; | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Good catch 👌 |
||
|
||
// remove all event listeners | ||
if(gd.removeAllListeners) gd.removeAllListeners(); | ||
|
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.Uh oh!
There was an error while loading. Please reload this page.
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 tozoom
. This is removed for a slightly different reason though: because the dragmode should not be affecting mousewheel behavior at all.Uh oh!
There was an error while loading. Please reload this page.
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 butgd._fullLayout.dragmode = 'zoom'
. That suggests it's sanitizing it but usinggd.layout.dragmode
instead ofgd._fullLayout.dragmode
. Actually settingdragmode: '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), notlayout.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
despitelayout.dragmode: false
not actually being a valid default. I'm okay with that.Uh oh!
There was an error while loading. Please reload this page.
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. 😄 🔪
Uh oh!
There was an error while loading. Please reload this page.
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.
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. 🎉