File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import ShareButton from "./ShareButton";
1111import Loader from "./ui/loader" ;
1212import { 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
1717interface 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 ( ( ) => {
You can’t perform that action at this time.
0 commit comments