Skip to content

Commit

Permalink
chore: Update package.json version to 1.0.194 and add image cropping …
Browse files Browse the repository at this point in the history
…functionality
  • Loading branch information
agjs committed Jul 28, 2024
1 parent 9a67a9b commit 9f0659e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@programmer_network/yail",
"version": "1.0.193",
"version": "1.0.194",
"description": "Programmer Network's official UI library for React",
"author": "Aleksandar Grbic - (https://programmer.network)",
"publishConfig": {
Expand Down
19 changes: 18 additions & 1 deletion src/Components/ImageCrop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ImageCrop: FC<IImageCropProps> = ({
const [scale] = useState(1);
const [rotate] = useState(0);

const onImageLoad = (e: React.SyntheticEvent<HTMLImageElement>) => {
const onImageLoad = async (e: React.SyntheticEvent<HTMLImageElement>) => {
if (!aspect) {
return;
}
Expand All @@ -52,6 +52,23 @@ const ImageCrop: FC<IImageCropProps> = ({
mediaHeight
)
);

if (!imgRef.current) {
return;
}

const { croppedImage, cropError } = await CanvasUtils.getCroppedImg(
imgRef.current,
crop
);

if (cropError) {
onError?.(cropError);

return;
}

onComplete?.(croppedImage as Blob);
};

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

0 comments on commit 9f0659e

Please sign in to comment.