Skip to content

Commit

Permalink
Update PDF.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsFlem authored Oct 23, 2024
1 parent 3c16ce5 commit 7b32fbe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/PDF.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React, { useEffect, useRef } from "react";
import "./PDF.css";

// Import the PDF file
import CV_PDF from "./_PDF/Lars_Flem_CV_english.pdf";

// Define the PdfViewer component
const PdfViewer: React.FC = () => {
const pdfRef = useRef<HTMLObjectElement>(null);

useEffect(() => {
if (pdfRef.current) {
// Calculate the height dynamically based on the window height
const windowHeight = window.innerHeight;
pdfRef.current.style.height = `${windowHeight - 150}px`; // Subtract header/footer or any margin as needed

if (window.innerWidth > 768) {
// Set height dynamically for larger screens
pdfRef.current.style.height = `${windowHeight - 150}px`; // Adjust as needed
} else {
// On mobile, allow scrolling and set auto height
pdfRef.current.style.height = "auto";
}
}
}, []);

Expand Down

0 comments on commit 7b32fbe

Please sign in to comment.