Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

refactor: disable zoom on mobile and vertical

Marc Seitzc02c0af320dc
diff --git a/components/view/PagesViewerNew.tsx b/components/view/PagesViewerNew.tsx
index 7f468aa3..cf144798 100644
--- a/components/view/PagesViewerNew.tsx
+++ b/components/view/PagesViewerNew.tsx
@@ -602,7 +602,8 @@ export default function PagesViewer({
isDataroom={dataroomId ? true : false}
setDocumentData={setDocumentData}
documentRefs={pinchRefs}
- disableZoom={isVertical && isMobile}
+ isVertical={isVertical}
+ isMobile={isMobile}
/>
<div
style={{ height: "calc(100dvh - 64px)" }}
diff --git a/components/view/nav.tsx b/components/view/nav.tsx
index 913f01f9..426adc10 100644
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@ -8,6 +8,7 @@ import { Brand, DataroomBrand } from "@prisma/client";
import {
ArrowUpRight,
Download,
+ Minimize2Icon,
Slash,
ZoomInIcon,
ZoomOutIcon,
@@ -53,7 +54,8 @@ export default function Nav({
isDataroom,
setDocumentData,
documentRefs,
- disableZoom,
+ isVertical,
+ isMobile,
}: {
pageNumber?: number;
numPages?: number;
@@ -68,7 +70,8 @@ export default function Nav({
isDataroom?: boolean;
setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
documentRefs?: MutableRefObject<(ReactZoomPanPinchContentRef | null)[]>;
- disableZoom?: boolean;
+ isVertical?: boolean;
+ isMobile?: boolean;
}) {
const downloadFile = async () => {
if (!allowDownload || type === "notion") return;
@@ -216,28 +219,50 @@ export default function Nav({
<Download className="h-5 w-5" />
</Button>
) : null}
- {!disableZoom && documentRefs ? (
+ {!(isVertical && isMobile) && documentRefs ? (
<div className="flex gap-1">
<Button
- onClick={() =>
- documentRefs.current[pageNumber! - 1]?.zoomIn()
- }
- className=" bg-gray-900 text-white hover:bg-gray-900/80"
+ onClick={() => {
+ if (isMobile) {
+ documentRefs.current[pageNumber! - 1]?.zoomIn();
+ return;
+ }
+ documentRefs.current.map((ref) => ref?.zoomIn());
+ }}
+ className="bg-gray-900 text-white hover:bg-gray-900/80"
size="icon"
title="Zoom in"
>
<ZoomInIcon className="h-5 w-5" />
</Button>
<Button
- onClick={() =>
- documentRefs.current[pageNumber! - 1]?.zoomOut()
- }
- className=" bg-gray-900 text-white hover:bg-gray-900/80"
+ onClick={() => {
+ if (isMobile) {
+ documentRefs.current[pageNumber! - 1]?.zoomOut();
+ return;
+ }
+ documentRefs.current.map((ref) => ref?.zoomOut());
+ }}
+ className="bg-gray-900 text-white hover:bg-gray-900/80"
size="icon"
title="Zoom out"
>
<ZoomOutIcon className="h-5 w-5" />
</Button>
+ <Button
+ onClick={() => {
+ if (isMobile) {
+ documentRefs.current[pageNumber! - 1]?.resetTransform();
+ return;
+ }
+ documentRefs.current.map((ref) => ref?.resetTransform());
+ }}
+ className="bg-gray-900 text-white hover:bg-gray-900/80"
+ size="icon"
+ title="Reset zoom"
+ >
+ <Minimize2Icon className="h-5 w-5" />
+ </Button>
</div>
) : null}
{pageNumber && numPages ? (