diff --git a/src/components/players/PdfPlayer/PdfPlayer.tsx b/src/components/players/PdfPlayer/PdfPlayer.tsx index 57b60dde..f9f37433 100644 --- a/src/components/players/PdfPlayer/PdfPlayer.tsx +++ b/src/components/players/PdfPlayer/PdfPlayer.tsx @@ -38,14 +38,20 @@ export const PdfPlayer: React.FunctionComponent = ({ const { t } = useTranslation(); const handleNextPageClick = () => { - if (onTopicEnd && allPages && !(allPages > currentPage)) { + if (onTopicEnd && allPages && !(allPages > currentPage + 1)) { setEndActionFired(true); onTopicEnd(); - return; } setCurrentPage(currentPage + 1); }; + const handlePrevPageClick = () => { + setCurrentPage(currentPage - 1); + if (endActionFired) { + setEndActionFired(false); + } + }; + React.useEffect(() => { pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`; setIsMounted(true); @@ -90,7 +96,7 @@ export const PdfPlayer: React.FunctionComponent = ({ mode="secondary" disabled={!(currentPage > 1)} className="nav-btn-modal" - onClick={() => setCurrentPage(currentPage - 1)} + onClick={handlePrevPageClick} > {t("Prev")}