mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
simplify comments
This commit is contained in:
parent
568cda1288
commit
4093ded628
@ -47,30 +47,15 @@ export function determineAutoZoom({
|
|||||||
return { type: 'fallback', zoom: Math.min(fitWidthZoom, fallbackZoom) };
|
return { type: 'fallback', zoom: Math.min(fitWidthZoom, fallbackZoom) };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Landscape pages need 100% visibility, portrait need 80%
|
// Landscape pages need 100% visibility, portrait need the specified threshold
|
||||||
const isLandscape = aspectRatio < 1;
|
const isLandscape = aspectRatio < 1;
|
||||||
const targetVisibility = isLandscape ? 100 : visibilityThreshold;
|
const targetVisibility = isLandscape ? 100 : visibilityThreshold;
|
||||||
|
|
||||||
// Step 1: Calculate what zoom level shows targetVisibility% (80%) of page height
|
// Calculate zoom level that shows targetVisibility% of page height
|
||||||
//
|
|
||||||
// At fitWidth, page dimensions are:
|
|
||||||
// pageHeightAtFitWidth = (viewportWidth / pagesPerSpread) * aspectRatio
|
|
||||||
//
|
|
||||||
// For 80% of page to be visible:
|
|
||||||
// viewportHeight / pageHeightAtZoom = targetVisibility / 100
|
|
||||||
// viewportHeight / (pageHeightAtFitWidth * zoomRatio) = targetVisibility / 100
|
|
||||||
//
|
|
||||||
// Where zoomRatio = heightBasedZoom / fitWidthZoom
|
|
||||||
//
|
|
||||||
// Solving:
|
|
||||||
// heightBasedZoom = fitWidthZoom * viewportHeight / (pageHeightAtFitWidth * targetVisibility / 100)
|
|
||||||
// heightBasedZoom = fitWidthZoom * (viewportHeight / pageHeightAtFitWidth) * (100 / targetVisibility)
|
|
||||||
|
|
||||||
const pageHeightAtFitWidth = (viewportWidth / pagesPerSpread) * aspectRatio;
|
const pageHeightAtFitWidth = (viewportWidth / pagesPerSpread) * aspectRatio;
|
||||||
const heightBasedZoom = fitWidthZoom * (viewportHeight / pageHeightAtFitWidth) / (targetVisibility / 100);
|
const heightBasedZoom = fitWidthZoom * (viewportHeight / pageHeightAtFitWidth) / (targetVisibility / 100);
|
||||||
|
|
||||||
// Step 2: Compare with fitWidth
|
// Use whichever zoom is smaller (more zoomed out) to satisfy both width and height constraints
|
||||||
// Use whichever is smaller (more zoomed out) to ensure both constraints are met
|
|
||||||
if (heightBasedZoom < fitWidthZoom) {
|
if (heightBasedZoom < fitWidthZoom) {
|
||||||
// Need to zoom out from fitWidth to show enough height
|
// Need to zoom out from fitWidth to show enough height
|
||||||
return { type: 'adjust', zoom: heightBasedZoom };
|
return { type: 'adjust', zoom: heightBasedZoom };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user