Skip to content
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

Fix that 3d view broke if it had no width #5588

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed "Create a new tree group for this file" setting in front-end import when a group id of 0 was used in the NML. [#5573](https://github.com/scalableminds/webknossos/pull/5573)
- Fixed a bug that caused a distortion when moving or zooming in the maximized 3d viewport. [#5550](https://github.com/scalableminds/webknossos/pull/5550)
- Fixed a bug that prevented focusing the login fields when being prompted to login after trying to view a dataset without being logged in.[#5521](https://github.com/scalableminds/webknossos/pull/5577)
- Fixed that the 3d view content disappeared permanently if the 3d view was resized to not be visible. [#5588](https://github.com/scalableminds/webknossos/pull/5588)

### Removed
-
Expand Down
8 changes: 4 additions & 4 deletions frontend/javascripts/oxalis/controller/camera_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ class CameraController extends React.PureComponent<Props> {
const oldWidth = tdCamera.right - tdCamera.left;
const oldHeight = tdCamera.top - tdCamera.bottom;

const oldAspectRatio = oldWidth / oldHeight;
const tdRect = inputCatcherRects[OrthoViews.TDView];
const newAspectRatio = tdRect.width / tdRect.height;

// Do not update the tdCamera if the tdView is not visible (height === 0)
if (Number.isNaN(newAspectRatio)) return;
// Do not update the tdCamera if the tdView is not visible
if (tdRect.height === 0 || tdRect.width === 0) return;

const oldAspectRatio = oldWidth / oldHeight;
const newAspectRatio = tdRect.width / tdRect.height;
const newWidth = (oldWidth * newAspectRatio) / oldAspectRatio;

tdCamera.left = oldMid - newWidth / 2;
Expand Down