Skip to content

Include gl3d scene.aspectmode changes in relayout updates #4579

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

Merged
merged 5 commits into from
Feb 14, 2020

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Feb 13, 2020

Follow up of #4578 this PR adds gl3d scene.aspectmode changes in relayout updates.

Demo

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Feb 13, 2020
@@ -219,6 +219,12 @@ proto.initializeGLPlot = function() {
if(scene.isAspectChanged(layout)) {
// scene updates
update[scene.id + '.aspectratio'] = scene.glplot.getAspectratio();

if(layout[scene.id].aspectmode !== 'manual') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we get back to the original aspectmode ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When resetting the view (e.g via the modebar buttons), yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I think we have some tests related to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it('sets aspectmode to manual when you provide any aspectratio', function(done) {
Plotly.plot(gd, [{x: [1, 2], y: [1, 2], z: [1, 2], type: 'scatter3d'}])
.then(function() {
expect(gd.layout.scene.aspectmode).toBe('auto');
return Plotly.relayout(gd, {'scene.aspectratio.x': 2});
})
.then(function() {
expect(gd.layout.scene.aspectmode).toBe('manual');
return Queue.undo(gd);
})
.then(function() {
expect(gd.layout.scene.aspectmode).toBe('auto');
})
.catch(failTest)
.then(done);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, to be clear, once a user scrolls into a orthographic scene, the aspectmode is turned to 'manual' and the only way to get back to original aspectmode is by resetting the view?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we should keep that in viewInitial props?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it handled currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apsectmode added to viewInitial in 1fdc49c and tests are added in 6ae2809.

@@ -790,6 +790,9 @@ proto.plot = function(sceneData, fullLayout, layout) {
y: fullSceneLayout.aspectratio.y,
z: fullSceneLayout.aspectratio.z
};

// also keep track of aspectmode here
scene.viewInitial.aspectmode = fullSceneLayout.aspectmode;
Copy link
Contributor

@etpinard etpinard Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be

if(!scene.viewInitial.aspectmode) {
  scene.viewInitial.aspectmode = fullSceneLayout.aspectmode
}

that way we don't override viewInitia.aspectmodel on updates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.
We could. Done in c730f12.

@etpinard
Copy link
Contributor

Thanks - 💃 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants