-
-
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
Keep orthographic zoom scales in fullLayout #4292
Conversation
src/plots/gl3d/scene.js
Outdated
@@ -243,7 +244,26 @@ function tryCreatePlot(scene, cameraObject, pixelRatio, canvas, gl) { | |||
} | |||
} | |||
|
|||
return failed < 2; | |||
if(failed < 2) { | |||
scene.wheelListener = mouseWheel(scene.glplot.canvas, function(dx, dy) { |
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.
A couple questions:
- why can't we add logic to this block:
plotly.js/src/plots/gl3d/scene.js
Lines 296 to 300 in 4a649f0
scene.glplot.canvas.addEventListener('wheel', function() { | |
if(gd._context._scrollZoom.gl3d) { | |
relayoutCallback(scene); | |
} | |
}, passiveSupported ? {passive: false} : false); |
which looks like also adds a mouse-wheel handler to the scene
- Shouldn't we also emit a
plotly_relayout
event with theaspectratio
keys just like we do here:
plotly.js/src/plots/gl3d/scene.js
Lines 283 to 290 in 4a649f0
var relayoutCallback = function(scene) { | |
if(scene.fullSceneLayout.dragmode === false) return; | |
var update = {}; | |
update[scene.id + '.camera'] = getLayoutCamera(scene.camera); | |
scene.saveCamera(gd.layout); | |
scene.graphDiv.emit('plotly_relayout', update); | |
}; |
for perspective projections?
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.
Addressed in fe19e47
@etpinard thanks very much for the review. |
- combine two wheel listeners - use gl-plot3d aspect setter and getter
src/plots/gl3d/scene.js
Outdated
update[scene.id + '.camera'] = getLayoutCamera(scene.camera); | ||
|
||
// scene updates | ||
update[scene.id + '.aspectratio'] = scene.glplot.getAspectratio(); |
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 should only part of the event data on scenes with orthographic projections
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.
... in other words, the event data should have the minimal set of keys that changed during the (here: scroll) interaction.
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.
Done in b92230a.
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.
And in d825c0e.
src/plots/gl3d/scene.js
Outdated
if(hasChanged) { | ||
var preGUI = {}; | ||
preGUI[this.id + '.camera'] = cameraDataLastSave; | ||
preGUI[this.id + '.aspectratio'] = aspectDataLastSave; |
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.
Here too, we should only store the aspectratio change for orthographic projections.
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.
Done in b92230a.
- consider aspectratio changes in modebar home and initial views - bump gl-plot3d 2.3.0
- test modebar with orthographic and add checks for initial aspect ratios - make sure plotly_relayout is emitted after each interaction
@etpinard This PR should be ready for another review. |
var aspectFullNP = Lib.nestedProperty(fullLayout, this.id + '.aspectratio'); | ||
aspectFullNP.set(aspectData); | ||
|
||
this.glplot.redraw(); |
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.
Hmm, why do we need to redraw here?
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.
We used to redraw in scene wheel listener after updating gl-plot3d.aspect
which is now moved to here so that we record the new before update.
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.
I guess that's ok, it's just feels a little odd to me that a method called saveLayout
ends up redrawing things in some cases.
Non-blocking.
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.
We could possibly make gl3d/scene.js
file more readable at one point.
I keep this in mind when we have time to refactor it in another PR.
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.
I keep this in mind when we have time to refactor it in another PR.
Awesome. Thank you very much cleaning up this code!!
Nicely done @archmoj - 💃 |
Fix #4274.
Orthographic scroll zoom changes
aspectratio
values. These changes should be reflected infullLayout
and alsorelayout
should be emitted.Before
After
In addition, there was a mistake noticed in calling arguments i.e. when try recovering the context which was fixed in d486dcd.
Also to mention commit 496059c simplifies calling arguments by applying scene
pixelRatio
.@plotly/plotly_js