Skip to content

Commit

Permalink
Only call onChange and onComplete in onImageLoaded if the crop is val…
Browse files Browse the repository at this point in the history
…id (has a width and height)
  • Loading branch information
sekoyo committed Oct 25, 2018
1 parent 80a0f07 commit 7ac1c34
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/ReactCrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function clamp(num, min, max) {
}

function isCropValid(crop) {
return crop && crop.width && crop.height;
return crop && crop.width && crop.height && !isNaN(crop.width) && !isNaN(crop.height);
}

function inverseOrd(ord) {
Expand Down Expand Up @@ -554,7 +554,7 @@ var ReactCrop = function (_PureComponent) {

// Generation of clientside crops will happen here so for convenience it's best to
// do it after an image ref has been saved from onImageLoaded.
if (resolvedCrop) {
if (resolvedCrop && isCropValid(resolvedCrop)) {
this.props.onChange(resolvedCrop, pixelCrop);
this.props.onComplete(resolvedCrop, pixelCrop);
}
Expand Down
Loading

2 comments on commit 7ac1c34

@mweibel
Copy link

@mweibel mweibel commented on 7ac1c34 Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dominictobias 👋 just FYI because I was looking into the changelog: I think this change has been published as 6.0.4 but the release page has not been updated yet. Thx :)

@sekoyo
Copy link
Owner Author

@sekoyo sekoyo commented on 7ac1c34 Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mweibel will update

Please sign in to comment.