Delete dead code

This commit is contained in:
James Brunton 2025-09-19 15:51:28 +01:00
parent 03eda04aec
commit 3af2e47bda
3 changed files with 2 additions and 57 deletions

View File

@ -119,7 +119,7 @@ const CropAreaSelector: React.FC<CropAreaSelectorProps> = ({
} 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<CropAreaSelectorProps> = ({
}
}, [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 (
<Box
ref={containerRef}
@ -237,27 +215,11 @@ function isPointInCropArea(x: number, y: number, domRect: DOMRect): boolean {
y >= 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;

View File

@ -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,

View File

@ -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
*/