mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-22 19:46:39 +00:00
Delete dead code
This commit is contained in:
parent
03eda04aec
commit
3af2e47bda
@ -119,7 +119,7 @@ const CropAreaSelector: React.FC<CropAreaSelectorProps> = ({
|
|||||||
|
|
||||||
} else if (isResizing) {
|
} else if (isResizing) {
|
||||||
// Resizing the crop area
|
// 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 constrainedRect = constrainDOMRectToThumbnail(newDomRect, pdfBounds);
|
||||||
const newCropArea = domToPDFCoordinates(constrainedRect, pdfBounds);
|
const newCropArea = domToPDFCoordinates(constrainedRect, pdfBounds);
|
||||||
onCropAreaChange(newCropArea);
|
onCropAreaChange(newCropArea);
|
||||||
@ -145,28 +145,6 @@ const CropAreaSelector: React.FC<CropAreaSelectorProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isDragging, isResizing, handleMouseMove, handleMouseUp]);
|
}, [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 (
|
return (
|
||||||
<Box
|
<Box
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
@ -237,27 +215,11 @@ function isPointInCropArea(x: number, y: number, domRect: DOMRect): boolean {
|
|||||||
y >= domRect.y && y <= domRect.y + domRect.height;
|
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(
|
function calculateResizedRect(
|
||||||
handle: ResizeHandle,
|
handle: ResizeHandle,
|
||||||
currentRect: DOMRect,
|
currentRect: DOMRect,
|
||||||
mouseX: number,
|
mouseX: number,
|
||||||
mouseY: number,
|
mouseY: number,
|
||||||
initialCropArea: CropArea,
|
|
||||||
pdfBounds: PDFBounds
|
|
||||||
): DOMRect {
|
): DOMRect {
|
||||||
let { x, y, width, height } = currentRect;
|
let { x, y, width, height } = currentRect;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BaseParameters } from '../../../types/parameters';
|
import { BaseParameters } from '../../../types/parameters';
|
||||||
import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters';
|
import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters';
|
||||||
import { useMemo, useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { CropArea, PDFBounds, constrainCropAreaToPDF, createFullPDFCropArea, roundCropArea } from '../../../utils/cropCoordinates';
|
import { CropArea, PDFBounds, constrainCropAreaToPDF, createFullPDFCropArea, roundCropArea } from '../../../utils/cropCoordinates';
|
||||||
|
|
||||||
export interface CropParameters extends BaseParameters {
|
export interface CropParameters extends BaseParameters {
|
||||||
@ -141,16 +141,6 @@ export const useCropParameters = (): CropParametersHook => {
|
|||||||
baseHook.updateParameter(parameter, value);
|
baseHook.updateParameter(parameter, value);
|
||||||
}, [baseHook]);
|
}, [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 {
|
return {
|
||||||
...baseHook,
|
...baseHook,
|
||||||
|
@ -186,13 +186,6 @@ export const isPointInThumbnail = (
|
|||||||
y <= pdfBounds.offsetY + pdfBounds.thumbnailHeight;
|
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
|
* Create a default crop area that covers the entire PDF
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user