From 25e1e7858c4965f9dc1c27b9622c4002e61a8ef6 Mon Sep 17 00:00:00 2001 From: LarsFlem <43146722+LarsFlem@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:09:23 +0200 Subject: [PATCH] Update PDF.tsx --- src/components/PDF.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/PDF.tsx b/src/components/PDF.tsx index f90ed78..e373d4b 100644 --- a/src/components/PDF.tsx +++ b/src/components/PDF.tsx @@ -1,16 +1,20 @@ import React, { useEffect, useRef, useState } 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 [isIOS, setIsIOS] = useState(false); - const pdfRef = useRef(null); + const iframeRef = useRef(null); // Ref for iframe + const objectRef = useRef(null); // Ref for object useEffect(() => { - const userAgent = window.navigator.userAgent; + const userAgent = navigator.userAgent || navigator.vendor || window.opera; // Detect iOS (iPhone/iPad) - if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { + if (/iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream) { setIsIOS(true); } }, []); @@ -18,24 +22,21 @@ const PdfViewer: React.FC = () => { return (

CV

- {isIOS ? ( - // Use an iframe for iOS devices or a link as a fallback ) : ( - // Use the object element for non-iOS devices