private getCanvasSize()

in src/component/minimap/Minimap.tsx [71:94]


  private getCanvasSize(workspace: DiagramMakerWorkspace, containerSize: Size, scale: number): Size {
    const { height: workspaceHeight, width: workspaceWidth } = workspace.canvasSize;
    const { height: containerHeight, width: containerWidth } = containerSize;

    const workspaceRatio = workspaceWidth / workspaceHeight;
    const containerRatio = containerWidth / containerHeight;

    let canvasWidth = containerWidth;
    let canvasHeight = containerHeight;

    if (workspaceRatio > containerRatio) {
      // Short and fat, fill empty space at the top and bottom
      canvasHeight = workspaceHeight / scale;
    } else {
      // Tall and thin, fill empty space at the left and right
      canvasWidth = workspaceWidth / scale;
    }

    const canvasSize = {
      height: canvasHeight,
      width: canvasWidth
    };
    return canvasSize;
  }