Skip to content

Commit 9f0659e

Browse files
committed
chore: Update package.json version to 1.0.194 and add image cropping functionality
1 parent 9a67a9b commit 9f0659e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.193",
3+
"version": "1.0.194",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/ImageCrop/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ImageCrop: FC<IImageCropProps> = ({
3030
const [scale] = useState(1);
3131
const [rotate] = useState(0);
3232

33-
const onImageLoad = (e: React.SyntheticEvent<HTMLImageElement>) => {
33+
const onImageLoad = async (e: React.SyntheticEvent<HTMLImageElement>) => {
3434
if (!aspect) {
3535
return;
3636
}
@@ -52,6 +52,23 @@ const ImageCrop: FC<IImageCropProps> = ({
5252
mediaHeight
5353
)
5454
);
55+
56+
if (!imgRef.current) {
57+
return;
58+
}
59+
60+
const { croppedImage, cropError } = await CanvasUtils.getCroppedImg(
61+
imgRef.current,
62+
crop
63+
);
64+
65+
if (cropError) {
66+
onError?.(cropError);
67+
68+
return;
69+
}
70+
71+
onComplete?.(croppedImage as Blob);
5572
};
5673

5774
const handleChange = (_: PixelCrop, percentCrop: PercentCrop) => {

0 commit comments

Comments
 (0)