Set zoom to 140%

This commit is contained in:
Reece Browne 2025-09-15 18:20:11 +01:00
parent 2834eec3be
commit 3755bfde34
2 changed files with 17 additions and 4 deletions

View File

@ -87,7 +87,7 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
// Register zoom plugin with configuration
createPluginRegistration(ZoomPluginPackage, {
defaultZoomLevel: 1.0, // Start at exactly 100% zoom
defaultZoomLevel: 1.4, // Start at 140% zoom for better readability
minZoom: 0.2,
maxZoom: 3.0,
}),

View File

@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useRef } from 'react';
import { useZoom } from '@embedpdf/plugin-zoom/react';
/**
@ -6,17 +6,30 @@ import { useZoom } from '@embedpdf/plugin-zoom/react';
*/
export function ZoomAPIBridge() {
const { provides: zoom, state: zoomState } = useZoom();
const hasSetInitialZoom = useRef(false);
// Set initial zoom once when plugin is ready
useEffect(() => {
if (zoom && !hasSetInitialZoom.current) {
hasSetInitialZoom.current = true;
setTimeout(() => {
console.log('Setting initial zoom to 140%');
zoom.requestZoom(1.4);
}, 50);
}
}, [zoom]);
useEffect(() => {
if (zoom) {
// Export zoom controls to global window for right rail access
(window as any).embedPdfZoom = {
zoomIn: () => zoom.zoomIn(),
zoomOut: () => zoom.zoomOut(),
toggleMarqueeZoom: () => zoom.toggleMarqueeZoom(),
requestZoom: (level: any) => zoom.requestZoom(level),
currentZoom: zoomState?.currentZoomLevel || 1,
zoomPercent: Math.round((zoomState?.currentZoomLevel || 1) * 100),
currentZoom: zoomState?.currentZoomLevel || 1.4,
zoomPercent: Math.round((zoomState?.currentZoomLevel || 1.4) * 100),
};
}