Skip to content

Fix MinZoom/MaxZoom having no effect on iOS#15

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-minzoom-property-ios
Draft

Fix MinZoom/MaxZoom having no effect on iOS#15
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-minzoom-property-ios

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

MinZoom and MaxZoom were silently ignored on iOS. When FitPolicy.Width is active, PDFKit's AutoScales = true overrides MinScaleFactor/MaxScaleFactor for gesture-based zooming, making it impossible to constrain zoom bounds declaratively. Additionally, the old EnableZoom setter applied MinZoom/MaxZoom as raw absolute scale factors rather than relative to the fit scale, so the values were semantically wrong even when they did get applied.

Changes

  • New ApplyZoomConstraints() method — sets MinScaleFactor = MinZoom × fitScale and MaxScaleFactor = MaxZoom × fitScale on the native PDFView, where fitScale is the scale factor computed by the active FitPolicy. This aligns iOS semantics with Android (where 1.0 = cannot zoom below fit, 3.0 = can zoom to 3× fit).

  • Deferred application via _needsZoomConstraintsApply flagApplyFitPolicy() sets the flag; LayoutSubviewsAction processes it once the view has valid bounds and a stable ScaleFactor. This handles both the initial load (where AutoScales hasn't settled yet) and runtime FitPolicy changes.

  • EnableZoom, MinZoom, MaxZoom are now reactive — each property stores a backing field and calls ApplyZoomConstraints() immediately (or defers if the document isn't loaded yet), so runtime updates propagate to the native layer.

<!-- MinZoom="1.0" now correctly prevents zooming out below fit-to-width on iOS -->
<pdf:PdfView EnableZoom="True"
             MinZoom="1.0"
             MaxZoom="3.0"
             FitPolicy="Width" />

The user-space workaround of setting nativePdfView.MinScaleFactor = nativePdfView.ScaleFactor in OnRendered is no longer needed.

… scale

- Add _enableZoom, _minZoom, _maxZoom backing fields to PdfViewiOS
- Add _needsZoomConstraintsApply deferred flag
- Convert EnableZoom getter to use _enableZoom backing field; setter now
  calls ApplyZoomConstraints() instead of setting MinScaleFactor directly
- Convert MinZoom/MaxZoom from auto-properties to backed properties that
  call ApplyZoomConstraints() on change
- Add ApplyZoomConstraints() that sets MinScaleFactor/MaxScaleFactor
  relative to the current fit scale (MinZoom * fitScale / MaxZoom * fitScale)
  and defers via _needsZoomConstraintsApply when the document isn't loaded
  or the view bounds aren't valid yet
- ApplyFitPolicy() now sets _needsZoomConstraintsApply = true so constraints
  are always re-applied after the fit scale changes
- LayoutSubviewsAction processes _needsZoomConstraintsApply flag, ensuring
  constraints are applied once the layout has valid bounds and scale factor

Fixes #14
Copilot AI changed the title [WIP] Fix MinZoom property effect on iOS Fix MinZoom/MaxZoom having no effect on iOS Jun 26, 2026
Copilot AI requested a review from michaelstonis June 26, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants