mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Improve code
This commit is contained in:
@@ -40,7 +40,7 @@ export function ImageCropper({ onCrop, onCancel, imageFile }: ImageCropperProps)
|
|||||||
reader.readAsDataURL(imageFile);
|
reader.readAsDataURL(imageFile);
|
||||||
}, [imageFile]);
|
}, [imageFile]);
|
||||||
|
|
||||||
const handleMouseDown = (e: React.MouseEvent) => {
|
function handleMouseDown(e: React.MouseEvent) {
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
|
||||||
const rect = canvasRef.current?.getBoundingClientRect();
|
const rect = canvasRef.current?.getBoundingClientRect();
|
||||||
@@ -57,7 +57,7 @@ export function ImageCropper({ onCrop, onCancel, imageFile }: ImageCropperProps)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseMove = (e: React.MouseEvent) => {
|
function handleMouseMove(e: React.MouseEvent) {
|
||||||
if (!isDragging || !isLoaded) return;
|
if (!isDragging || !isLoaded) return;
|
||||||
|
|
||||||
const rect = canvasRef.current?.getBoundingClientRect();
|
const rect = canvasRef.current?.getBoundingClientRect();
|
||||||
@@ -72,11 +72,11 @@ export function ImageCropper({ onCrop, onCancel, imageFile }: ImageCropperProps)
|
|||||||
setCropArea(prev => ({ ...prev, x: newX, y: newY }));
|
setCropArea(prev => ({ ...prev, x: newX, y: newY }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseUp = () => {
|
function handleMouseUp() {
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCrop = () => {
|
function handleCrop() {
|
||||||
if (!canvasRef.current || !imageRef.current || !isLoaded) return;
|
if (!canvasRef.current || !imageRef.current || !isLoaded) return;
|
||||||
|
|
||||||
const canvas = canvasRef.current;
|
const canvas = canvasRef.current;
|
||||||
@@ -99,7 +99,7 @@ export function ImageCropper({ onCrop, onCancel, imageFile }: ImageCropperProps)
|
|||||||
onCrop(croppedImageData);
|
onCrop(croppedImageData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawCropArea = () => {
|
function drawCropArea() {
|
||||||
if (!canvasRef.current || !imageRef.current || !isLoaded) return;
|
if (!canvasRef.current || !imageRef.current || !isLoaded) return;
|
||||||
|
|
||||||
const canvas = canvasRef.current;
|
const canvas = canvasRef.current;
|
||||||
|
|||||||
Reference in New Issue
Block a user