From 03dc0c8c1be8b1ee633e96a7ece855e9f67266b2 Mon Sep 17 00:00:00 2001 From: Wu Peirong Date: Wed, 26 Oct 2022 23:47:49 +0800 Subject: [PATCH] [resumes][fix] padding on pdf view in mobile --- .../src/components/resumes/ResumePdf.tsx | 21 +++++++------------ packages/ui/src/Pagination/Pagination.tsx | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/portal/src/components/resumes/ResumePdf.tsx b/apps/portal/src/components/resumes/ResumePdf.tsx index 4a4c3a42..514c061a 100644 --- a/apps/portal/src/components/resumes/ResumePdf.tsx +++ b/apps/portal/src/components/resumes/ResumePdf.tsx @@ -24,20 +24,15 @@ export default function ResumePdf({ url }: Props) { setNumPages(pdf.numPages); }; - useEffect(() => { - const onPageResize = () => { - setComponentWidth( - document.querySelector('#pdfView')?.getBoundingClientRect().width ?? - 780, - ); - }; - - window.addEventListener('resize', onPageResize); + const onPageResize = () => { + setComponentWidth( + document.querySelector('#pdfView')?.getBoundingClientRect().width ?? 780, + ); + }; - return () => { - window.removeEventListener('resize', onPageResize); - }; - }, []); + useEffect(() => { + onPageResize(); + }, [pageWidth]); return (
diff --git a/packages/ui/src/Pagination/Pagination.tsx b/packages/ui/src/Pagination/Pagination.tsx index 59c72a36..6ce812b4 100644 --- a/packages/ui/src/Pagination/Pagination.tsx +++ b/packages/ui/src/Pagination/Pagination.tsx @@ -85,7 +85,7 @@ export default function Pagination({ } if (lastAddedPage < current - pagePadding - 1) { - elements.push(); + elements.push(); } for (let i = current - pagePadding; i <= current + pagePadding; i++) { @@ -93,7 +93,7 @@ export default function Pagination({ } if (lastAddedPage < end - pagePadding - 1) { - elements.push(); + elements.push(); } for (let i = end - pagePadding; i <= end; i++) {