From 17c4b7be325df177d784b44f374f1ffc56469ab0 Mon Sep 17 00:00:00 2001 From: ShouryaUpadhyaya Date: Sun, 12 Oct 2025 16:05:43 +0530 Subject: [PATCH] fix zoom change on fullscreen --- src/components/pdfViewer.tsx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/components/pdfViewer.tsx b/src/components/pdfViewer.tsx index 3cf3c27..35d8ffd 100644 --- a/src/components/pdfViewer.tsx +++ b/src/components/pdfViewer.tsx @@ -11,7 +11,7 @@ import ShareButton from "./ShareButton"; import Loader from "./ui/loader"; import { FaGreaterThan, FaLessThan } from "react-icons/fa6"; -pdfjs.GlobalWorkerOptions.workerSrc = +pdfjs.GlobalWorkerOptions.workerSrc = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.8.69/pdf.worker.min.mjs"; interface PdfViewerProps { @@ -159,26 +159,14 @@ export default function PdfViewer({ url, name }: PdfViewerProps) { }, []); useEffect(() => { - if (containerRef.current) { - const containerWidth = containerRef.current.offsetWidth; - - const initialScale = containerWidth / 800; - setScale(initialScale > 1 ? 1 : initialScale); - } - }, []); - - useEffect(() => { - const calculateScale = () => { + const calculateInitialScale = () => { if (containerRef.current) { const containerWidth = containerRef.current.offsetWidth; const initialScale = containerWidth / 800; setScale(initialScale > 1 ? 1 : initialScale); } }; - - calculateScale(); - window.addEventListener("resize", calculateScale); - return () => window.removeEventListener("resize", calculateScale); + calculateInitialScale(); }, []); useEffect(() => {