Skip to content

Canvas scales down but does not scale up when viewport is resized #237

Description

@williamthorsen

Problem

The Excalibur game canvas correctly scales down when the browser viewport is reduced in size, but it does not scale back up when the viewport is increased.

Investigation

The canvas uses DisplayMode.FitContainer with fixed engine dimensions (1200×600). The codebase has no resize event handling — no window.addEventListener('resize'), no ResizeObserver, and no manual engine screen resize calls.

When the viewport shrinks, CSS constraints (width: 100%) cause the canvas to shrink. When the viewport grows, Excalibur has no mechanism to detect the container size change and recalculate scaling.

Likely fix

Add a ResizeObserver on the canvas container element that triggers Excalibur's screen resize when the container dimensions change. This could be added in GameCanvas.tsx or CatwalkCanvas.tsx.

Key files

  • packages/factory/src/client/components/GameCanvas.tsx — Engine creation with DisplayMode.FitContainer
  • packages/factory/src/client/components/CatwalkCanvas.tsx — Similar setup
  • packages/factory/src/client/components/GameCanvas.css — Container styling with aspect-ratio: 2/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions