From 3af2e47bdab9e07f8da967e09c38635dd8199d5a Mon Sep 17 00:00:00 2001 From: James Brunton Date: Fri, 19 Sep 2025 15:51:28 +0100 Subject: [PATCH] Delete dead code --- .../tools/crop/CropAreaSelector.tsx | 40 +------------------ .../src/hooks/tools/crop/useCropParameters.ts | 12 +----- frontend/src/utils/cropCoordinates.ts | 7 ---- 3 files changed, 2 insertions(+), 57 deletions(-) diff --git a/frontend/src/components/tools/crop/CropAreaSelector.tsx b/frontend/src/components/tools/crop/CropAreaSelector.tsx index d92f464cd..d49e5e61c 100644 --- a/frontend/src/components/tools/crop/CropAreaSelector.tsx +++ b/frontend/src/components/tools/crop/CropAreaSelector.tsx @@ -119,7 +119,7 @@ const CropAreaSelector: React.FC = ({ } else if (isResizing) { // Resizing the crop area - const newDomRect = calculateResizedRect(isResizing, domRect, x, y, initialCropArea, pdfBounds); + const newDomRect = calculateResizedRect(isResizing, domRect, x, y); const constrainedRect = constrainDOMRectToThumbnail(newDomRect, pdfBounds); const newCropArea = domToPDFCoordinates(constrainedRect, pdfBounds); onCropAreaChange(newCropArea); @@ -145,28 +145,6 @@ const CropAreaSelector: React.FC = ({ } }, [isDragging, isResizing, handleMouseMove, handleMouseUp]); - // Update cursor based on mouse position - const getCursor = useCallback((clientX: number, clientY: number): string => { - if (disabled || !containerRef.current) return 'default'; - - const rect = containerRef.current.getBoundingClientRect(); - const x = clientX - rect.left; - const y = clientY - rect.top; - - if (!isPointInThumbnail(x, y, pdfBounds)) return 'default'; - - const handle = getResizeHandle(x, y, domRect); - if (handle) { - return getResizeCursor(handle); - } - - if (isPointInCropArea(x, y, domRect)) { - return 'move'; - } - - return 'crosshair'; - }, [disabled, pdfBounds, domRect]); - return ( = domRect.y && y <= domRect.y + domRect.height; } -function getResizeCursor(handle: ResizeHandle): string { - const cursors = { - 'nw': 'nw-resize', - 'ne': 'ne-resize', - 'sw': 'sw-resize', - 'se': 'se-resize', - 'n': 'n-resize', - 'e': 'e-resize', - 's': 's-resize', - 'w': 'w-resize' - }; - return cursors[handle!] || 'default'; -} - function calculateResizedRect( handle: ResizeHandle, currentRect: DOMRect, mouseX: number, mouseY: number, - initialCropArea: CropArea, - pdfBounds: PDFBounds ): DOMRect { let { x, y, width, height } = currentRect; diff --git a/frontend/src/hooks/tools/crop/useCropParameters.ts b/frontend/src/hooks/tools/crop/useCropParameters.ts index aa1712fc3..871818f90 100644 --- a/frontend/src/hooks/tools/crop/useCropParameters.ts +++ b/frontend/src/hooks/tools/crop/useCropParameters.ts @@ -1,6 +1,6 @@ import { BaseParameters } from '../../../types/parameters'; import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters'; -import { useMemo, useCallback } from 'react'; +import { useCallback } from 'react'; import { CropArea, PDFBounds, constrainCropAreaToPDF, createFullPDFCropArea, roundCropArea } from '../../../utils/cropCoordinates'; export interface CropParameters extends BaseParameters { @@ -141,16 +141,6 @@ export const useCropParameters = (): CropParametersHook => { baseHook.updateParameter(parameter, value); }, [baseHook]); - // Calculate crop area percentage of original PDF - const getCropPercentage = useCallback((pdfBounds?: PDFBounds): number => { - if (!pdfBounds) return 100; - - const cropArea = getCropArea(); - const totalArea = pdfBounds.actualWidth * pdfBounds.actualHeight; - const cropAreaSize = cropArea.width * cropArea.height; - - return (cropAreaSize / totalArea) * 100; - }, [getCropArea]); return { ...baseHook, diff --git a/frontend/src/utils/cropCoordinates.ts b/frontend/src/utils/cropCoordinates.ts index 5309a9734..6ad225572 100644 --- a/frontend/src/utils/cropCoordinates.ts +++ b/frontend/src/utils/cropCoordinates.ts @@ -186,13 +186,6 @@ export const isPointInThumbnail = ( y <= pdfBounds.offsetY + pdfBounds.thumbnailHeight; }; -/** - * Get the aspect ratio of the PDF - */ -export const getPDFAspectRatio = (pdfBounds: PDFBounds): number => { - return pdfBounds.actualWidth / pdfBounds.actualHeight; -}; - /** * Create a default crop area that covers the entire PDF */