Skip to content

Commit 9aef412

Browse files
Merge pull request #393 from ShouryaUpadhyaya/staging
Fix: Zoom level isn't remembered when I exist full screen #367
2 parents 3540840 + 17c4b7b commit 9aef412

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

src/components/pdfViewer.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ShareButton from "./ShareButton";
1111
import Loader from "./ui/loader";
1212
import { FaGreaterThan, FaLessThan } from "react-icons/fa6";
1313

14-
pdfjs.GlobalWorkerOptions.workerSrc =
14+
pdfjs.GlobalWorkerOptions.workerSrc =
1515
"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.8.69/pdf.worker.min.mjs";
1616

1717
interface PdfViewerProps {
@@ -159,26 +159,14 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
159159
}, []);
160160

161161
useEffect(() => {
162-
if (containerRef.current) {
163-
const containerWidth = containerRef.current.offsetWidth;
164-
165-
const initialScale = containerWidth / 800;
166-
setScale(initialScale > 1 ? 1 : initialScale);
167-
}
168-
}, []);
169-
170-
useEffect(() => {
171-
const calculateScale = () => {
162+
const calculateInitialScale = () => {
172163
if (containerRef.current) {
173164
const containerWidth = containerRef.current.offsetWidth;
174165
const initialScale = containerWidth / 800;
175166
setScale(initialScale > 1 ? 1 : initialScale);
176167
}
177168
};
178-
179-
calculateScale();
180-
window.addEventListener("resize", calculateScale);
181-
return () => window.removeEventListener("resize", calculateScale);
169+
calculateInitialScale();
182170
}, []);
183171

184172
useEffect(() => {

0 commit comments

Comments
 (0)