Skip to content

A scroll container zooms its one child by pinch on iOS - #11

Merged
janicduplessis merged 1 commit into
mainfrom
@janic/scroll-zoom-pinch
Nov 15, 2026
Merged

janicduplessis merged 1 commit into
mainfrom
@janic/scroll-zoom-pinch

Conversation

@janicduplessis

Copy link
Copy Markdown

Description

minimumZoomScale, maximumZoomScale and zoomScale on a scroll container with one child are UIScrollView's own zoom on iOS. A pinch scales the child about the fingers through the range, with UIKit's bounce at both ends. zoomScale is the scale the scroller opens at, and the one it moves to when the value changes. Other hosts ignore the three.

The child keeps its layout. UIKit zooms a view of its own, placed over the child. The child is drawn from the scroller's scale through hostPlacement, so its own transform, a press and an animation compose with the zoom. 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.

This is based on #10, the sync with expo/exact a107143. Retarget it to main once #10 merges.

Notes

  • The three props are ids 312, 313 and 314 in kernel/tables/schema.json, after the sync's 310 and 311, and the schema digest is recomputed.
  • Upstream moved scroll restoring out of Presenter.apply into restoreScrollPositions (ScrollViewIOS.swift). settleZoom() runs there, after a scroller's position is restored and before any authored offset lands.

Test plan

  • cargo test -p exact-kernel --lib wire::codec, and bun scripts/caps.mjs is within every cap.
  • An app built against this branch passes all 44 of its web contract tests in Chrome. That app uses none of the three zoom props, so this only shows the commit doesn't break the build or other behavior. I haven't exercised the pinch itself on this branch.

minimumZoomScale, maximumZoomScale and zoomScale on a scroll with one child are UIScrollView's own zoom: a pinch scales the child about the fingers through the range, with UIKit's bounce at both ends, and zoomScale is where it opens and where it goes when the value changes. UIKit zooms a view of its own placed over the child; the child is drawn from the scroller's scale through hostPlacement, so its transform, a press and an animation compose with it. The child keeps its layout: the extent grows by its size times the scale, and it is centred while the whole is smaller than the port. Other hosts ignore the three.
@janicduplessis
janicduplessis changed the base branch from @janic/sync-upstream to main November 15, 2026 03:40
@janicduplessis
janicduplessis marked this pull request as ready for review November 15, 2026 03:40
@janicduplessis
janicduplessis merged commit 9c03c37 into main Nov 15, 2026
2 checks passed
@janicduplessis
janicduplessis deleted the @janic/scroll-zoom-pinch branch November 15, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant