Skip to content

Commit

Permalink
fix: prevent situation where width is defined and 0 (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscb authored Oct 20, 2023
1 parent 68026b8 commit 54470e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions typescript/packages/subsurface-viewer/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function calculateZoomFromBBox3D(
return camera;
}

if (typeof deck === "undefined") {
if (!deck?.width || !deck?.height) {
camera_.zoom = 0;
camera_.target = [0, 0, 0];
return camera_;
Expand Down Expand Up @@ -1299,7 +1299,7 @@ function getViewState3D(

let width = xMax - xMin;
let height = yMax - yMin;
if (deck) {
if (deck && deck?.width > 0 && deck?.height > 0) {
width = deck.width;
height = deck.height;
}
Expand Down Expand Up @@ -1349,7 +1349,13 @@ function createViewsAndViewStates(

const mPixels = views?.marginPixels ?? 0;

const isOk = deck && views && views.layout[0] >= 1 && views.layout[1] >= 1;
const isOk =
deck &&
views &&
views.layout[0] >= 1 &&
views.layout[1] >= 1 &&
widthViewPort > 0 &&
heightViewPort > 0;

// if props for multiple viewport are not proper, or deck is not yet initialized, return 2d view
if (!isOk) {
Expand Down

0 comments on commit 54470e6

Please sign in to comment.