Skip to content

[Docs/Enhancement] Canvas sizes to the window, not its container #95

Description

@SamuelAB-VIM

Environment

  • vim-web 1.0.0-alpha.0, IIFE build (dist/vim-web.iife.js) loaded via <script>
  • API: VIM.Core.Webgl.createViewer() (headless, custom UI)
  • Chromium / desktop, devicePixelRatio 1.75
  • Model: 2,547 elements (2,264 with geometry), 12 Revit categories, structural

Summary. After createViewer() + reparent()/appendChild(), the canvas CSS size equals
the window (e.g. 1300×1102), so it overflows a smaller container and paints over
sibling UI. Calling viewer.viewport.resizeToParent() fixes it.

Repro / fix.

viewer.viewport.reparent(myColumn);        // myColumn is 860px wide
// canvas is now 1300px wide (window), overflowing ❌
viewer.viewport.resizeToParent();          // canvas → 860px ✅
window.addEventListener('resize', () => viewer.viewport.resizeToParent());

Asks. Either document that resizeToParent() must be called after reparenting (and on
window resize), or have the viewport auto-observe its parent via a ResizeObserver by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions