githubnext/chopinPublic

Let's compose rich plans together

Keep pinch zoom optical instead of reflowing the workspace #392

MergedMaggieAppletonmerged 4 commits intomainfromrefs/pull/392/head
  1. MA

    ## Why

    On a Mac trackpad (or a phone), pinch-to-zoom in Chopin enlarged the whole page layout instead of magnifying a region like other sites. `useVisualViewport` sizes `#root` from `window.visualViewport` so the workspace stays above the on-screen keyboard. A pinch zoom also shrinks and moves the visual viewport, so the app re-laid itself out inside the zoomed region: at 2x on a 1440×900 window, `#root` became 720×450, the layout switched to the compact tabbed workspace, and the browser then magnified that.

    ## What changed

    - `viewportVars` follows the visual viewport only when `visualViewport.scale` is ~1 (keyboard and browser-chrome cases). While pinch zoomed it keeps the layout viewport (`left/top 0`, width 100%, height `innerHeight`), so the browser zooms optically. - Unit tests for the zoomed and keyboard-shifted cases. - E2E: a 2x pinch zoom (CDP `Emulation.setPageScaleFactor`) on a 1440×900 desktop keeps `#root` at 1440×900 and the split layout. The existing visual-viewport keyboard tests all emulate scale 1 and are unchanged.

    ## Screenshots

    Desktop 1440×900 after a 2× pinch at (720, 300). Before, the workspace reflowed into the zoomed region; after, the desktop layout is magnified around the pinch point.

    ![Before pinch](https://github.com/user-attachments/assets/53dc51e4-ca2a-4946-9e21-9e0547c64800) ![After pinch](https://github.com/user-attachments/assets/a3f2134c-549b-4524-b80e-910455ebd2f5) ![After unzoomed](https://github.com/user-attachments/assets/1bf34283-2cfa-410d-855d-b42c46fa9d73)

    Measured in headless Chromium with the same gesture: before `#root` = 360,150 720×450; after `#root` = 0,0 1440×900 while `visualViewport` = 360,150 720×450 scale 2.

    ## Verification

    - Four commits, including the `currentViewport()` simplification, remain patch-identical on the refreshed stack. - Focused viewport tests: 5 passed. `bun run fix`, `bun run ci`, `bun run types`, and `bun run build` passed; the reviewed viewport design hash is renewed. - Initial JavaScript is 251,596 B raw / 79,415 B gzip, 4,404 bytes below the raw limit. Fresh GitHub CI must run after the prepared head is published.

  2. MaggieAppletonauto-rebase-enabledlast month on GitHub

  3. MaggieAppletonauto-merge-disabledlast month on GitHub

  4. MaggieAppletonhead-ref-force-pushed 0d3b3ddd2737last month on GitHub

  5. MaggieAppletonmerged cd40d0f538cdlast month on GitHub

  6. MaggieAppletonclosedlast month on GitHub

  7. MaggieAppletonhead-ref-deletedlast month on GitHub