feat(plugin-zoom): add usePhysicalScaling option#671
Open
JoackimPennerup wants to merge 1 commit into
Open
Conversation
When enabled, numeric zoom values are treated as user-space/logical values and multiplied by (96/72) x devicePixelRatio to produce the effective render scale. This makes 100% zoom map to physical inches on-screen (Acrobat-style), where 1 PDF point equals roughly 1.333 CSS pixels on a 96 DPI display. Changes: - ZoomPluginConfig.usePhysicalScaling?: boolean (opt-in, default false) - ZoomDocumentState.currentUserZoomLevel: number - user-space scale exposed for UI display (toolbar, translation strings) - ZoomScope.getDpr() / ZoomCapability.getDpr() - returns the active (96/72) x devicePixelRatio multiplier, or 1 when disabled - handleRequest splits numeric and mode paths: numeric clamps in user-space then scales by DPR; mode path returns effective scale unchanged - zoomIn/zoomOut/requestZoomBy operate in user-space throughout - handleZoomToArea clamps fit-ratio in effective-space to preserve full range - DPR-change listener with 150ms debounce recalculates open documents on display scale change; listener torn down in destroy() - Gesture utilities (pinch, wheel) convert initialZoom to user-space before computing delta, preventing double-application of the DPR factor - Snippet toolbar and translation strings read currentUserZoomLevel so the displayed percentage always reflects the user-space value - pnpm-workspace.yaml: exclude .vercel build artifacts from workspace scan Backwards compatibility: when usePhysicalScaling is unset (default false), getDpr() returns 1 and currentUserZoomLevel === currentZoomLevel at all times, preserving bit-identical behaviour with previous releases.
|
@JoackimPennerup is attempting to deploy a commit to the OpenBook Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is handles #670 as an opt-in option to the zoom plugin.
When enabled, numeric zoom values are treated as user-space/logical values and multiplied by (96/72) x devicePixelRatio to produce the effective render scale. This makes 100% zoom map to physical inches on-screen (Acrobat-style), where 1 PDF point equals roughly 1.333 CSS pixels on a 96 DPI display.
Changes:
Backwards compatibility: when usePhysicalScaling is unset (default false), getDpr() returns 1 and currentUserZoomLevel === currentZoomLevel at all times, preserving bit-identical behaviour with previous releases.