Skip to content

Fix zoom glitch and add smart zoom for margin cropping#6

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-zoom-functionality
Draft

Fix zoom glitch and add smart zoom for margin cropping#6
Copilot wants to merge 3 commits intomainfrom
copilot/fix-zoom-functionality

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

Zoom in/out from fit-to-width mode used the stale zoomScale (default 1.0) as base instead of the actual PDFView scale factor, causing erratic jumps. Smart zoom added to maximize screen utilization.

Root cause

When fitToWidth = true, PDFKit's autoScales manages the scale factor independently (e.g. 0.7×). Pressing + computed 1.0 * 1.25 = 1.25 instead of 0.7 * 1.25 = 0.875, producing a jarring jump.

Changes

  • Scale factor sync: LectorPDFView now observes PDFViewScaleChanged and writes the actual scaleFactor back to AppState.viewScaleFactor
  • Zoom step fix: zoomIn/zoomOut use viewScaleFactor as base when transitioning from fit-to-width, zoomScale otherwise
    case .zoomIn:
        let base = fitToWidth ? viewScaleFactor : zoomScale
        fitToWidth = false
        zoomScale = min(base * 1.25, 10.0)
  • Smart zoom (w key, :smartzoom): Toggles between fit-to-width and a tighter zoom that eliminates margin whitespace by comparing the page's cropBox to its mediaBox and scaling by the width ratio

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 7, 2026 06:20
- Track actual PDFView scale factor via viewScaleFactor property
- Use actual view scale as base when zooming from fitToWidth mode
- Add smartZoom command that toggles between fitToWidth and margin crop
- Add 'w' keybinding and ':smartzoom'/':sz' command mode aliases
- Update help panel and README documentation

Co-authored-by: herbertwxin <28001854+herbertwxin@users.noreply.github.com>
Co-authored-by: herbertwxin <28001854+herbertwxin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix zoom functionality for better usability Fix zoom glitch and add smart zoom for margin cropping Mar 7, 2026
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.

2 participants