Skip to content

iOS: pinch to zoom a scroll container's one child (minimumZoomScale, maximumZoomScale, zoomScale) #666

Open

Description

@janicduplessis

What happened

There is no way to let a person pinch-zoom content on iOS: a photo, a diagram, a map drawn in the page, or a large board. UIScrollView has this built in (minimumZoomScale, maximumZoomScale, zoomScale, viewForZooming(in:)), but Contract's scroll does not expose it.

Request

Three attributes on a scroll container with one child, mapped to UIScrollView's own zoom on iOS:

  • minimumZoomScale and maximumZoomScale: the range a pinch scales the child through, about the fingers, with UIKit's bounce at both ends;
  • zoomScale: the scale the scroller opens at, and the one it moves to when the value changes.

The child keeps its layout. The scroller's extent grows by the child's size times the scale, and the child is centred while the whole is smaller than the port, as a photo viewer does. Other hosts could ignore the three until they have an equivalent.

How a fork built it

appandflow/exact#11 adds the three props (kernel/tables/schema.json, lowered in contract/lower/src/tags.rs, listed in the vocab card) and a new ScrollZoomIOS.swift:

  • UIKit zooms a proxy view of its own, inserted under the child, which viewForZooming(in:) returns. The child itself is not the zoom view, because a node's transform belongs to the host (applyTransform), and a view with two writers shows whichever wrote last.
  • The child is drawn from the scroller's scale through hostPlacement (zoomFactor, zoomShift), so its own transform, press feedback and animations compose with the zoom.
  • settleZoom() runs after a batch, in restoreScrollPositions, after a scroller's position is restored and before any authored offset lands. It applies the range and any new zoomScale, and not while the person is zooming or UIKit is bouncing.
  • scrollViewDidZoom re-places the child and queues a scroll event.
  • A scroller with no valid range (missing, non-finite, or max <= min), or with more than one child, drops the zoom and puts the child back as layout placed it.

Caveat: the fork's build was checked with codec tests and an app's web contract tests, but the pinch itself was not exercised on that branch.

Host

iOS

Smallest app that shows it

The proposed usage. A compiler without the change refuses it with lower-unknown-attr (scroll has no attribute minimumZoomScale).

component App
  view
    scroll width="100%" height="100%" minimumZoomScale=1 maximumZoomScale=4 zoomScale=1
      column width=600 height=600 background-image="linear-gradient(45deg, #e53935, #1e88e5)"
        text "Pinch me"

Exact commit

f3a4ace. Upstream's kernel/tables/schema.json has no zoom-scale prop, and no iOS file implements viewForZooming(in:) for a scroller.

Activity

  1. ccheever commented on Nov 15, 2026

    @ccheever
    Contributor

    Decided, after a three-model panel (unanimous): a zoomable scroller belongs in Exact, but as one vocabulary on every host, not UIKit's names on iOS alone. An RFC extending LLP 1057.001 will define an -exact- property on a scroller with one child, mapped to UIScrollView zoom on iOS and NSScrollView magnification on macOS, emulated elsewhere or refused by name. Your proxy-view technique is the likely iOS half. The RFC goes through review before it's built.

    Posted by Claude Code on the maintainers' behalf.

  2. ccheever commented on Nov 15, 2026

    @ccheever
    Contributor

    Progress under LLP 1057.001.000, "Zoomable scrollers". It went through a three-model panel check and a full review before any code.

    • Vocabulary (1a4f774): a scroll container takes a zoom range through -exact- rows, the scrollZoom command writes its zoom, and ScrollEvent.scrollZoom reports it.
    • iOS (3514b23): UIScrollView zoom. A real two-finger pinch reaches 1.78 and stops at 4 and 1. A double tap zooms to 2, and a press on content that isn't a control is held until a second tap can no longer come. A smaller child is centred, with padding and margins left unscaled.
    • macOS (65065d2): NSScrollView magnification. A pinch keeps the point under it still.
    • Web (b416d7a): an emulation loaded only by apps that use it. Touch pinch, trackpad pinch and double tap all work, and each gesture ends with exactly one scrollend.
    • Gallery (cb717d2): the interaction gallery's viewer has a zoomable photo with Fit and 2×.

    Still to build: the painted hosts (Linux, Windows, Android) drawing the child scaled, with pinch and double tap, and Windows touch pinch. This issue stays open until those land.

    Posted by Claude Code on the maintainers' behalf.

  3. ccheever commented on Nov 15, 2026

    @ccheever
    Contributor

    Progress on the zoomable scroller (LLP 1057.001.000, steps 5 and 6): Android, Linux and Windows now zoom a scroller's one child, in 2f544b330, 77c04b454 and b90240ad5.

    • Android: a real two-finger pinch zooms the photo (to 207% on the emulator), and a double tap zooms to 200% about the tap. While zoomed, one finger pans and flings, and ctrl+wheel zooms from a mouse.
    • Linux: ctrl+wheel zooms about the pointer. Headless, the 2× screenshot matches the web's.
    • Windows: a second finger starts a pinch. This is tested with a unit test and a cross-compile only; it has not been run on Windows hardware.
    • Web: three fixes in 9111553dc. The inspector no longer reports the runtime's touch-action as authored. A prerendered page shows the zoomed child at its real height before boot instead of collapsing. That prerender was also throwing on any zoomable app, which is fixed.

    I'm leaving this open until it has run on Windows hardware. Still queued: zoomed images on the painted hosts are decoded at their unzoomed size, so a photo at 4× is soft.

    Posted by Claude Code on the maintainers' behalf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions