Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Revert "feat: improve zoom for documents"
Marc Seitzfb534f0be8e7
diff --git a/components/view/PagesViewerNew.tsx b/components/view/PagesViewerNew.tsxindex 7117fc45..b432d5e5 100644--- a/components/view/PagesViewerNew.tsx+++ b/components/view/PagesViewerNew.tsx@@ -269,7 +269,7 @@ export default function PagesViewer({if (!container) return;const scrollPosition = container.scrollTop;- const pageHeight = container.scrollHeight / numPagesWithAccountCreation;+ const pageHeight = container.clientHeight;const currentPage = Math.floor(scrollPosition / pageHeight) + 1;const currentPageFraction = (scrollPosition % pageHeight) / pageHeight;@@ -412,8 +412,7 @@ export default function PagesViewer({if (isVertical) {scrollActionRef.current = true;const newScrollPosition =- ((pageNumber - 2) * containerRef.current!.scrollHeight) /- numPagesWithAccountCreation;+ (pageNumber - 2) * containerRef.current!.clientHeight;containerRef.current?.scrollTo({top: newScrollPosition,behavior: "smooth",@@ -428,8 +427,7 @@ export default function PagesViewer({if (isVertical) {scrollActionRef.current = true;const newScrollPosition =- ((pageNumber - 2) * containerRef.current!.scrollHeight) /- numPagesWithAccountCreation;+ (pageNumber - 2) * containerRef.current!.clientHeight;containerRef.current?.scrollTo({top: newScrollPosition,behavior: "smooth",@@ -455,8 +453,7 @@ export default function PagesViewer({if (isVertical) {scrollActionRef.current = true;const newScrollPosition =- ((pageNumber - 2) * containerRef.current!.scrollHeight) /- numPagesWithAccountCreation;+ (pageNumber - 2) * containerRef.current!.clientHeight;containerRef.current?.scrollTo({top: newScrollPosition,behavior: "smooth",@@ -475,8 +472,7 @@ export default function PagesViewer({if (isVertical) {scrollActionRef.current = true;const newScrollPosition =- (pageNumber * containerRef.current!.scrollHeight) /- numPagesWithAccountCreation;+ pageNumber * containerRef.current!.clientHeight;containerRef.current?.scrollTo({top: newScrollPosition,behavior: "smooth",@@ -503,10 +499,7 @@ export default function PagesViewer({if (isVertical) {scrollActionRef.current = true;- const newScrollPosition =- (pageNumber * containerRef.current!.scrollHeight) /- numPagesWithAccountCreation;- console.log("newScrollPosition", newScrollPosition);+ const newScrollPosition = pageNumber * containerRef.current!.clientHeight;containerRef.current?.scrollTo({top: newScrollPosition,behavior: "smooth",@@ -621,44 +614,21 @@ export default function PagesViewer({<TransformWrapperkey={index}initialScale={scale}- initialPositionX={0}- initialPositionY={0}- panning={{- // disabled: isVertical,- lockAxisY: isVertical,- velocityDisabled: true,- wheelPanning: false,- }}- wheel={{ disabled: true }}- pinch={{ disabled: true }}- doubleClick={{ disabled: true }}+ panning={{ disabled: scale === 1, velocityDisabled: true }}+ wheel={{ disabled: scale === 1 }}onZoom={(ref) => {setScale(ref.state.scale);}}ref={(ref) => {pinchRefs.current[index] = ref;}}- customTransform={(x: number, y: number, scale: number) => {- // Keep the translateY value constant- if (isVertical) {- const transform = `translate(${x}px, ${index * y * -2}px) scale(${scale})`;- return transform;- }- const transform = `translate(${x}px, ${y}px) scale(${scale})`;- return transform;- }}>- <TransformComponent- wrapperClass={cn(- isVertical && "!overflow-x-clip !overflow-y-visible",- )}- contentClass={cn(isVertical && "!w-screen")}- >+ <TransformComponent><divkey={index}style={{ height: "calc(100vh - 64px)" }}className={cn(- "relative w-full",+ "relative h-screen w-full",pageNumber - 1 === index? "block": !isVerticaldiff --git a/components/view/nav.tsx b/components/view/nav.tsxindex 29c57387..90837916 100644--- a/components/view/nav.tsx+++ b/components/view/nav.tsx@@ -8,7 +8,6 @@ import { Brand, DataroomBrand } from "@prisma/client";import {ArrowUpRight,Download,- Minimize2Icon,Slash,ZoomInIcon,ZoomOutIcon,@@ -219,9 +218,9 @@ export default function Nav({<div className="flex gap-1"><ButtononClick={() =>- documentRefs.current.map((ref) => ref?.zoomIn())+ documentRefs.current[pageNumber! - 1]?.zoomIn()}- className="bg-gray-900 text-white hover:bg-gray-900/80"+ className=" bg-gray-900 text-white hover:bg-gray-900/80"size="icon"title="Zoom in">@@ -229,24 +228,14 @@ export default function Nav({</Button><ButtononClick={() =>- documentRefs.current.map((ref) => ref?.zoomOut())+ documentRefs.current[pageNumber! - 1]?.zoomOut()}- className="bg-gray-900 text-white hover:bg-gray-900/80"+ 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={() =>- 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 ? (